Serge,
Won't lie, read this from my phone this morning and thought 'No it can't be
that easy'.
Now that I'm at work in front of a computer I've updated the command to the
following:
GetTarget.ps1
________________________________
###############
## Variables ##
###############
$cred = New-Object System.Management.Automation.PSCredential -ArgumentList
@('[email protected]',(ConvertTo-SecureString -String 'MyPassword'
-AsPlainText -Force))
$command = Invoke-Command -computername localhost -credential $cred
-scriptblock {& Get-IscsiServerTarget -TargetName Target1 | select-object
TargetIqn,Status | Format-List} -SessionOption (New-PSSessionOption
-SkipCACheck -SkipCNCheck -SkipRevocationCheck)
#########################
## Execute Scriptblock ##
#########################
$command
________________________________
And it returns:
________________________________
Array
(
[0] =>
[1] =>
[2] => TargetIqn : iqn.2013-04.com.widget:Target1
[3] => Status : NotConnected
[4] =>
[5] =>
[6] =>
)
0
End Of Scene
________________________________
In effect, you're a genius!
Thank you for all your help I should be able to tackle it from here!
Alan Loos
CONFIDENTIALITY NOTICE: This e-mail and the attachment(s) hereto (if any)
contain confidential information that is privileged and intended only for the
addressee(s) hereof. If you are not an intended recipient, you are hereby
notified that any disclosure, copying, distribution or use of this e-mail
and/or the accompanying attachment(s) is strictly prohibited. If you have
received this e-mail in error, please immediately notify the sender by return
e-mail.
From: Serge Fonville [mailto:[email protected]]
Sent: Monday, July 22, 2013 4:09 AM
To: Alan Loos
Cc: [email protected]
Subject: Re: [PHP] PHP and Powershell
Hi,
Thanks for your change.
I understand what has happend, from MSDN forums
http://social.technet.microsoft.com/Forums/windowsserver/en-US/4b841530-9d8c-4d09-a77c-b89c6e0bafab/how-do-i-capture-data-from-invokecommand
http://technet.microsoft.com/en-us/library/jj612804.aspx describes that
Get-IscsiServerTarget returns an instance of
Microsoft.Iscsi.Target.Commands.IscsiServerTarget. De output also includes the
runspaceid and pscomputername. Invoke-Command also returns a runspaceid (when
executed with -computername).
You need to use Select-Object to output only the relevant fields instead.
HTH
Kind regards/met vriendelijke groet,
Serge Fonville
http://www.sergefonville.nl
Convince Microsoft!
They need to add TRUNCATE PARTITION in SQL Server
https://connect.microsoft.com/SQLServer/feedback/details/417926/truncate-partition-of-partitioned-table
--Snip--
--Big Snip--
Please make note of my new email address: [email protected].