regarding local admin user account in windows 10

M

manikandan_2306

Hi Guys,

I have prepared a powershell script to create local admin user account and I have planned to push it through Intune. There are totally 700 pc's in my Organisation.

I want to know is there any option to have a local user admin account which should be working even when the PC is out of Organisation Domain.


Below is the script that I have prepared to create local admin account through Intune:


$Username = "test"

$Password = "Password12345"

$Description = "Local Admin Account"

$group = "Administrators"

$adsi = [ADSI]"WinNT://$env:COMPUTERNAME"

$existing = $adsi.Children | where {$_.SchemaClassName -eq 'user' -and $_.Name -eq $Username }

if ($existing -eq $null) {

Write-Host "Creating new local user $Username."

& NET USER $Username $Password /add /y /expires:never

& net user $USERNAME /comment:"Local Admin Account”

& net user $USERNAME /fullname:"$Username"

Write-Host "Adding local user $Username to $group."

& NET LOCALGROUP $group $Username /add



}else {

Write-Host "Setting password for existing local user $Username."

$existing.SetPassword($Password)

}

Write-Host "Ensuring password for $Username never expires."

& WMIC USERACCOUNT WHERE "Name='$Username'" SET PasswordExpires=FALSE

Continue reading...
 
Back
Top Bottom