Ορίστε τι βρήκα στηγν αναζήτησή μου για ένα PS script που να διαχειρίζεται
ορισμένα VMs είναι του αγαπητού συναδέλφου
Randy Williams. Εγώ μόνο πρόσθεσα την "stop" procedure , γιατίο ο ίδιος είχε μόνον την "start" and "save"
Param($operation, $servername)
if ($operation -eq 'start')
{
$stateId = 2
}
elseif ($operation -eq 'save')
{
$stateId = (32769)
}
elseif ($operation -eq 'stop')
{
$stateId = 3
}
else
{ "Unknown operation"
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
throw
}
#Get a handle to the VM object
$Core = get-wmiobject -namespace root\virtualization -class Msvm_Computersystem -filter "ElementName = '$servername'"
#Set the state
$status = $Core.RequestStateChange($stateId)
#Are we already in this state?
if ($status.ReturnValue -eq 32775)
{
"Already in this state"
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
#Wait for use to press key if it did not work successfully
#0 = Success; 4096 = Job Running
elseif (($status.ReturnValue -ne 0) -and ($status.ReturnValue -ne 4096))
{
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
Για να κάνετε τον WS2008 να εκτελεί non-signed PS scripts τοπικά γράψτε μέσα στο PS shell
Set-ExecutionPolicy RemoteSigned
νομίζω πως είναι πολύ καλό σκριπτάκι
Θανάσης Ζανιδάκης
Virtualize IT !