I’m a powershell-newb. My goal is to rename pc’s and afterwards release the ip address and shut them down… remotely.
I’m guessing my problem is understanding exactly how enter-pssession works. I was hoping all commands applied to that session while connected. The rename part works perfectly. After the rename, my goal is to physically move the computer to a different subnet, so I would like to release the ip and shut them down. I have no clue how to script, I’m just now learning the basics of powershell and so far this is what I have:
$OldComputername= Read-Host 'Enter Old PC Name' $NewComputerName= Read-Host 'Enter New PC Name' Enter-PSSession -ComputerName $OldComputername -Credential domain\user Rename-Computer -ComputerName $OldComputername -NewName $NewComputerName -DomainCredential domain\user | ...
I’ve tried cmd commands like ipconfig /release followed by shutdown -s -t 10, but these commands only applied to my local session. I’ve even tried to call upon a .bat file saved locally on the pc that I know could also perform the release/shutdown function I need, but I can’t figure out how to start the .bat file using enter-possession.
Any tips, criticisms, ideas are all welcome.
Thanks for reading…