Misc
add-type -assemblyName PresentationCore
$clip = [Windows.Clipboard]::GetDataObject()
if ('Csv' -in $clip.GetFormats()) {$mem = $clip.GetData('Csv'); $buf = [byte[]]::new($mem.length); $null = $mem.Read($buf, 0, $mem.length)}; $x = ''; foreach ($c in $buf) { $x = $x += [char]$c} ; $x
add-type -assemblyName PresentationCore
$clip = [Windows.Clipboard]::GetDataObject()
foreach ($fmt in $clip.GetFormats()) {
try {
$dat = $clip.GetData($fmt)
$typ = $dat.GetType()
}
catch {
$typ = '?'
}
'{0,-50} {1}' -f $fmt, $typ
}
Memory stream to text:
add-type -assemblyName PresentationCore
$clip = [Windows.Clipboard]::GetDataObject()
$mem = $clip.GetData('Xml Spreadsheet')
$enc = [System.Text.Encoding]::GetEncoding("ISO-8859-1")
$str = $enc.GetString($mem.ToArray())
write-host $str