Monday, June 26, 2023

PS Scripts - Set Windows Registered User and Organization


Here's a quick and easy PowerShell script to set Windows registered owner and organization. The script will automatically set the owner as the logged user.

Tip: Use it during Autopilot deployment so you can have this information automatically added after the assigned user sign-in.

# Define registered organization name
$strCurrentUserName = $env:UserName
$strOrganizationName = "Your Organization Name"
$path = 'HKLM:\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion'
$key = try {
Get-Item -Path $path -ErrorAction STOP
}
catch {
#New-Item -Path $path -Force
}
New-ItemProperty -Path $key.PSPath -Name RegisteredOwner -Value $strCurrentUserName -Force
New-ItemProperty -Path $key.PSPath -Name RegisteredOrganization -Value $strOrganizationName -Force

No comments:

Post a Comment