Created
September 24, 2015 18:17
-
-
Save jpda/375707054983fbdb429e to your computer and use it in GitHub Desktop.
Windows 10 IoT Password/Name Change
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Param ( | |
| [string]$IP,[string]$Name,[string]$Password | |
| ) | |
| $stockPass = ConvertTo-SecureString "p@ssw0rd" -AsPlainText -Force # Default password | |
| $securePass = ConvertTo-SecureString $Password -AsPlainText -Force # new target password | |
| $stockCreds = New-Object System.Management.Automation.PSCredential("$IP\Administrator", $stockPass) | |
| $newCreds = New-Object System.Management.Automation.PSCredential("$IP\Administrator", $securePass) | |
| Get-Service -Name WinRM | Start-Service -Verbose # Ensure WS-Man is started | |
| Set-Item WSMan:\localhost\Client\TrustedHosts -Value "$IP,$Name" -Force -Verbose # Add the target machine to your trusted hosts | |
| #change password | |
| Invoke-Command -ComputerName $IP -Credential $stockCreds -ScriptBlock { | |
| & net user Administrator $using:Password # built-in net command in Windows | |
| } -Verbose | |
| #change name | |
| Invoke-Command -ComputerName $IP -Credential $newCreds -ScriptBlock { | |
| & setcomputername $using:Name # simple utilities in W10 IoT | |
| & shutdown /r /t 0 | |
| } -Verbose |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment