{"id":2280,"date":"2019-10-01T10:58:07","date_gmt":"2019-10-01T08:58:07","guid":{"rendered":"http:\/\/les-fougs.com\/wordpress\/?p=2280"},"modified":"2019-10-01T13:42:37","modified_gmt":"2019-10-01T11:42:37","slug":"power-off-power-on-powercli","status":"publish","type":"post","link":"http:\/\/les-fougs.com\/wordpress\/2019\/10\/01\/power-off-power-on-powercli\/","title":{"rendered":"Power OFF &#8211; Power ON PowerCLI"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<p class=\"has-background has-bright-red-background-color\">  ATTENTION avec Vtom : la  queue_ps1 doit contenir :  <br><br>%PATH_POWERSHELL%\\powershell.exe -ExecutionPolicy <strong>UnRestricted<\/strong> -NonInteractive -File %TOM_SCRIPT% %arg% <\/p>\n\n\n\n<p> <em>Tests fait sur VWJES_TST et PRD.<\/em> <\/p>\n\n\n\n<p class=\"has-text-color has-bright-red-color\"><strong> Lancer Windows Power Shell en administrateur <\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">PowerShell Set-ExecutionPolicy UnRestricted   \n\nL:\\Soft\\VMware\\Scripts\\Initialize-PowerCLIEnvironment.ps1   \n\nConnect-VIServer -Server wctsrv0001.wabtec.com -Protocol https -User ad.wabtec.com\\srvWCTVtom -Password 'Y------#' \n\nGet-PowerCLIConfiguration \n\nSet-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false \n\nGet-Vm vsch1 \n\nStart-Vm vsch1 \n\nStop-Vm vsch1 <\/pre>\n\n\n\n<p>&#8212;&#8211; Autres commandes <\/p>\n\n\n\n<p>Get-Help Set-ExecutionPolicy <\/p>\n\n\n\n<p>PowerShell Set-ExecutionPolicy AllSigned <\/p>\n\n\n\n<p>&#8212;- script &#8212; <\/p>\n\n\n\n<p style=\"font-size:-5px\">\/\/WCTSRV0016\/Batch_win\/vtom_VM_power.ps1 <em> <\/em><br>P1 :  <em>nom_du_serveur<\/em> <br>P2 :  <em>start <\/em>ou<em> stop<\/em>  <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Param( \n [string]$w_vm = $Args[0],\n [string]$w_action = $Args[1]\n )\n Write-Host \"La VM est : $w_vm\"\n Write-Host \"Action : $w_action\"\n PowerShell Set-ExecutionPolicy UnRestricted\n L:\\Soft\\VMware\\Scripts\\Initialize-PowerCLIEnvironment.ps1 -w_vm -w_action \n Connect-VIServer -Server wctsrv0001.wabtec.com -Protocol https -User ad.wabtec.com\\srvWCTVtom -Password 'YN6$P&amp;G6j#'\n $WarningPreference = 'SilentlyContinue'\n $Error.Clear()\n Get-VM \"$w_vm\" |select Name, PowerState\n if ( $w_action -like \"stop\" ) {\n Stop-VM -VM \"$w_vm\" -Confirm:$false\n $statu = Get-VM \"$w_vm\" |select PowerState\n     if ( $statu -like \"@{PowerState=PoweredOff}\" ) {\n         Write-Host \"Power : OFF\"\n         exit 0\n     } else {\n         Write-Host \"Power : ON\"\n         exit 1\n     }\n } else {\n Start-VM -VM \"$w_vm\" -Confirm:$false\n $statu = Get-VM \"$w_vm\" |select PowerState\n     if ( $statu -like \"@{PowerState=PoweredOn}\" ) {\n         Write-Host \"Power : ON\"\n         exit 0\n     } else {\n         Write-Host \"Power : OFF\"\n         exit 1\n         }\n }<\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>ATTENTION avec Vtom : la queue_ps1 doit contenir : %PATH_POWERSHELL%\\powershell.exe -ExecutionPolicy UnRestricted -NonInteractive -File %TOM_SCRIPT% %arg% Tests fait sur VWJES_TST et PRD. Lancer Windows Power Shell en administrateur PowerShell Set-ExecutionPolicy UnRestricted L:\\Soft\\VMware\\Scripts\\Initialize-PowerCLIEnvironment.ps1 Connect-VIServer -Server wctsrv0001.wabtec.com -Protocol https -User ad.wabtec.com\\srvWCTVtom -Password &lsquo;Y&#8212;&#8212;#&rsquo; Get-PowerCLIConfiguration Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false Get-Vm vsch1 Start-Vm vsch1 Stop-Vm vsch1 &#8212;&#8211; Autres commandes &hellip; <a href=\"http:\/\/les-fougs.com\/wordpress\/2019\/10\/01\/power-off-power-on-powercli\/\" class=\"more-link\">Continuer la lecture<span class=\"screen-reader-text\"> de &laquo;&nbsp;Power OFF &#8211; Power ON PowerCLI&nbsp;&raquo;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[54],"tags":[67,68],"_links":{"self":[{"href":"http:\/\/les-fougs.com\/wordpress\/wp-json\/wp\/v2\/posts\/2280"}],"collection":[{"href":"http:\/\/les-fougs.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/les-fougs.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/les-fougs.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/les-fougs.com\/wordpress\/wp-json\/wp\/v2\/comments?post=2280"}],"version-history":[{"count":10,"href":"http:\/\/les-fougs.com\/wordpress\/wp-json\/wp\/v2\/posts\/2280\/revisions"}],"predecessor-version":[{"id":2291,"href":"http:\/\/les-fougs.com\/wordpress\/wp-json\/wp\/v2\/posts\/2280\/revisions\/2291"}],"wp:attachment":[{"href":"http:\/\/les-fougs.com\/wordpress\/wp-json\/wp\/v2\/media?parent=2280"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/les-fougs.com\/wordpress\/wp-json\/wp\/v2\/categories?post=2280"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/les-fougs.com\/wordpress\/wp-json\/wp\/v2\/tags?post=2280"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}