Skip to content

Instantly share code, notes, and snippets.

@dpo007 dpo007/ComputerRenamer.ps1
Last active Jan 14, 2020

Embed
What would you like to do?
PowerShell script :: Wraps Rename-Computer, for use during scheduled/remote launches on Domain-Attached machines.
#################
# 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
You can’t perform that action at this time.