Answer the question
In order to leave comments, you need to log in
Powercli, Powershell VM authorization check?
Hello. there is a task. checking authorization in a virtual machine in vCenter ESXi
In vCenter ESXi, for example, there is a CLIENTM virtual machine, you need to check authorization on the machine, if the login and password are not correct, it gives an error, if it is correct, it displays that the authorization has passed.
Now I made a crutch like this
If (Invoke-VMScript -vm $CLIENTM -ScriptText "ipconfig" -GuestUser '[email protected]' -GuestPassword '[email protected]' -ScriptType Powershell)
{Invoke-VMScript -vm $CLIENTM -ScriptText "echo LOGIN FOR IZHEVSk YES" -GuestUser '[email protected]' -GuestPassword '[email protected]' -ScriptType Powershell | Out-File D:\result.txt -Append -NoClobber}
ElseIf (Invoke-VMScript -vm $CLIENTM -ScriptText "ipconfig" -GuestUser '[email protected]' -GuestPassword '[email protected]' -ScriptType Powershell)
{Invoke-VMScript -vm $CLIENTM -ScriptText "echo LOGIN FOR MOSCOW YES IZHEVSk NO" -GuestUser '[email protected]' -GuestPassword '[email protected]' -ScriptType Powershell | Out-File D:\result.txt -Append -NoClobber}
Else
{Invoke-VMScript -vm $CLIENTM -ScriptText "echo LOGIN FOR IZHEVSk and MOSCOW NO" -GuestUser '[email protected]' -GuestPassword '[email protected]' -ScriptType Powershell | Out-File D:\result.txt -Append -NoClobber}
If (Invoke-VMScript -vm $CLIENTM -ScriptText "ipconfig" -GuestUser '[email protected]' -GuestPassword '[email protected]' -ScriptType Powershell)
{Invoke-VMScript -vm $CLIENTM -ScriptText "echo LOGIN FOR MOSCOW YES" -GuestUser '[email protected]' -GuestPassword '[email protected]' -ScriptType Powershell | Out-File D:\result.txt -Append -NoClobber}
Else
{Invoke-VMScript -vm $CLIENTM -ScriptText "echo LOGIN FOR IZHEVSk and MOSCOW NO" -GuestUser '[email protected]' -GuestPassword '[email protected]' -ScriptType Powershell | Out-File D:\result.txt -Append -NoClobber}
ScriptOutput
-----------------------------------------------------------------------------------------------------------------------| LOGIN
| FOR
| IZHEVSk
| YES
|
-----------------------------------------------------------------------------------------------------------------------
ScriptOutput
-----------------------------------------------------------------------------------------------------------------------| LOGIN
| FOR
| MOSCOW
| YES
|
-----------------------------------------------------------------------------------------------------------------------
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question