Just wanted to ask if it is somehow possible to use StarWindX cmdlets while running a PowerShell script on a remote computer. Here is my code:
Code: Select all
param (
$tapeLibMachine
)
$mycreds = ConvertTo-SecureString "MyPassword" -AsPlainText -Force | % {New-Object System.Management.Automation.PSCredential ("$tapeLibMachine\Administrator", $_)}
$scriptBlock = {
try {
Import-Module StarWindX
$server = New-SWServer -host 127.0.0.1 -port 3261 -user root -password starwind
Enable-SWXLog
$server.Connect()
}
catch {
$errDescription = $Error[0].Exception.Message
"Error occured: $errDescription"
}
finally {
$server.Disconnect()
}
}
Invoke-Command -Computername $tapeLibMachine -Credential $mycreds -ScriptBlock $scriptBlock
Code: Select all
C:\Scripts\>powershell .\test.ps1 avo-vtl
StarWindX doesn't support current appartment. You need to run this script with -STA switch to use StarWindX.
At C:\Scripts\test.ps1:32 char:1
+ Invoke-Command -Computername $tapeLibMachine -Credential $mycreds -ScriptBlock $ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (StarWindX doesn... use StarWindX.:String) [], RuntimeException
+ FullyQualifiedErrorId : StarWindX doesn't support current appartment. You need to run this script with -STA switch to use StarWindX.
Any chances to make it work?
Thank you.