VMware Cloud Community
baber
Expert
Expert

How can set answer due vm powercli script

I am writing a script this is applying on hosts but it ask question and need to respond it so how can set it to respond Y 

Write-Output "40- esxi-7.shell-disable" | Green
Get-VMHost | Get-VMHostService -VMHost * | where {$_.Key -eq 'TSM'} | Set-VMHostService -Policy Off
Get-VMHost | Get-VMHostService -VMHost * | where {$_.Key -eq 'TSM'} | Stop-VMHostService

For example it shows follow :

 

PS C:\Users\Administrator> Get-VMHostService -VMHost * | where {$_.Key -eq 'TSM'} | Stop-VMHostService

Perform operation?
Perform operation Stop host service. on ESXi Shell?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):

 

I want it set auto answer Y

 

Please mark helpful or correct if my answer resolved your issue.
Reply
0 Kudos
3 Replies
scott28tt
VMware Employee
VMware Employee

As this post also needs moving to the area for PowerCLI, I have also reported it to the volunteer moderators.

 


-------------------------------------------------------------------------------------------------------------------------------------------------------------

Although I am a VMware employee I contribute to VMware Communities voluntarily (ie. not in any official capacity)
VMware Training & Certification blog
Reply
0 Kudos
LucD
Leadership
Leadership

Add the -Confirm:$false switch on the Stop-VMHostService cmdlet


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
LucD
Leadership
Leadership

Did this answer your question?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos