When I run below script from local machine on the server name stired ub vnfqdn.txt, script pauses and asks me to enter username and credentials. I want to provide password automatically in the script in secured way. can you help me to add any command in below scrip which can help.
$hostname=get-content C:\temp\vmfqdn.txt
$patchetest=Invoke-Command -ComputerName $hostname -Credential domain\username -ScriptBlock {(Get-HotFix -id "KB4534271").HotFixID}
if($patchetest -eq "KB4534271"){
write-host("Patch KB4534271 is installed")
} else {
write-host("Patch is not installed")
}
'''
how to add credentials in power shell script, so that when i run the script it wont ask for password, I do not want password to be seen in the script.
note- Above script works fine when I provide password manually when window asking for password prompts up.