DekGenius.com
SHELL
join computer to domain powershell script
$dc = "ENTERPRISE"
$pw = "Password123" | ConvertTo-SecureString -asPlainText -Force
$usr = "$dcT.Simpson"
$pc = "WKS034, WKS052, WKS057" # Specify the computers that should be joined to the domain.
$creds = New-Object System.Management.Automation.PSCredential($usr$pw)
Add-Computer -ComputerName $pc -LocalCredential $pcadmin -DomainName $dc -Credential $creds -Restart -Force
join computer to domain powershell script
$dc = "ENTERPRISE"
$pw = "Password123" | ConvertTo-SecureString -asPlainText -Force
$usr = "$dcT.Simpson"
$pc = "R07GF"
$creds = New-Object System.Management.Automation.PSCredential($usr,$pw)
Remove-Computer -ComputerName $pc -Credential $creds –Verbose –Restart –Force
join computer to domain powershell script
$File="C:scriptsComputers.csv" # Specify the import CSV position.
$Path="OU=Devices,DC=enterprise,DC=com" # Specify the path to the OU.
Import-Csv -Path $File | ForEach-Object { New-ADComputer -Name $_.Computer -Path $Path -Enabled $True}
join computer to domain powershell script
$dc = "ENTERPRISE" # Specify the domain to join.
$pw = "Password123" | ConvertTo-SecureString -asPlainText –Force # Specify the password for the domain admin.
$usr = "$dcT.Simpson" # Specify the domain admin account.
$creds = New-Object System.Management.Automation.PSCredential($usr,$pw)
Add-Computer -DomainName $dc -Credential $creds -restart -force -verbose # Note that the computer will be restarted automatically.
join computer to domain powershell script
New-ADComputer –Name “WKS932” –SamAccountName “WKS932”
join computer to domain powershell script
Remove-ADObject -Identity "WKS932"
join computer to domain powershell script
Get-Content C:scriptscomputersfordeletion.txt | % { Get-ADComputer -Filter { Name -eq $_ } } | Remove-ADObject -Recursive
join computer to domain powershell script
$stale = (Get-Date).AddDays(-30) # means 30 days since last logon, can be changed to any number.
Get-ADComputer -Property Name,lastLogonDate -Filter {lastLogonDate -lt $stale} | FT Name,lastLogonDate
Get-ADComputer -Property Name,lastLogonDate -Filter {lastLogonDate -lt $stale} | Remove-ADComputer
© 2022 Copyright:
DekGenius.com