How can I set thread and start it with some executable code with ApartmentState = "STA"
? I just find this method but I don't know how I can pass my scriptblock to it.
$r = [RunspaceFactory]::CreateRunspace()
$r.ApartmentState = 'STA'
$r.Open()
I need to get clipboard text in this thread, like this:
$getclipboardtext = [System.Windows.Clipboard]::GetText()
$getclipboardtext | Out-File c:\examplepath
I also tried Start-Job
.