Last active
January 14, 2020 20:38
-
-
Save dpo007/104c09da58fa3ad910e3f47958d8cefa to your computer and use it in GitHub Desktop.
PowerShell script :: Wraps Rename-Computer, for use during scheduled/remote launches on Domain-Attached machines.
This file contains 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
################# | |
# Wrapper for Rename-Computer | |
# - Intended to be used with an RMM/automated script launcher. | |
# - DPO, Jan. 2020 | |
################# | |
param ( | |
[Parameter(Mandatory=$True)] | |
[string]$NewName, | |
[Parameter(Mandatory=$True)] | |
[string]$DomainCreds, | |
[Parameter(Mandatory=$True)] | |
[string]$DomPass | |
) | |
$plainPass = $DomPass | ConvertTo-SecureString -asPlainText -Force | |
$credential = New-Object System.Management.Automation.PSCredential($DomainCreds, $plainPass) | |
Write-Host "Renaming `"$env:computername`" to `"$NewName`", and then rebooting..." | |
Rename-Computer -NewName $NewName -DomainCredential $credential -Force -Restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment