Sunday, 31 May 2020

How to Add Logon Workstation through Csv file in Active Directory PowerShell Command.

How to Add Logon Workstation through Csv file in Active Directory PowerShell Command.




Csv file format









Bulk Workstations Add through CSV file

# Add LogonWorkstation through Csv File
Import-Module ActiveDirectory
$machineList = Import-Csv -Path "C:\PClist.csv" | ForEach-Object {$_.NetBIOSName}
$UserProperties = Get-ADUser -Identity pri9 -Properties LogonWorkstations
$comparry = ($UserProperties).LogonWorkstations
foreach($machine in $machineList)
{
   $comparry += "," +$machine

}
Set-ADUser -Identity Pri9 -LogonWorkstations $comparry

# For Checking

Get-ADUser pri9 -Properties LogonWorkstations




2 comments: