“Dołącz do komputera do domeny PowerShell Script” Kod odpowiedzi

Dołącz do komputera do domeny PowerShell Script

$dc = "ENTERPRISE"
$pw = "Password123" | ConvertTo-SecureString -asPlainText -Force
$usr = "$dc\T.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 $pc\admin -DomainName $dc -Credential $creds -Restart -Force
Joyous Jay

Dołącz do komputera do domeny 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
Joyous Jay

Dołącz do komputera do domeny PowerShell Script

$dc = "ENTERPRISE" # Specify the domain to join.
$pw = "Password123" | ConvertTo-SecureString -asPlainText –Force # Specify the password for the domain admin.
$usr = "$dc\T.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.
Joyous Jay

Dołącz do komputera do domeny PowerShell Script

$dc = "ENTERPRISE"
$pw = "Password123" | ConvertTo-SecureString -asPlainText -Force
$usr = "$dc\T.Simpson"
$pc = "R07GF"
$creds = New-Object System.Management.Automation.PSCredential($usr,$pw)
Remove-Computer -ComputerName $pc -Credential $creds –Verbose –Restart –Force
Joyous Jay

Dołącz do komputera do domeny PowerShell Script

$File="C:\scripts\Computers.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}
Joyous Jay

Dołącz do komputera do domeny PowerShell Script

Get-Content C:\scripts\computersfordeletion.txt | % { Get-ADComputer -Filter { Name -eq $_ } } | Remove-ADObject -Recursive
Joyous Jay

Dołącz do komputera do domeny PowerShell Script

New-ADComputer –Name “WKS932” –SamAccountName “WKS932”
Joyous Jay

Dołącz do komputera do domeny PowerShell Script

Remove-ADObject -Identity "WKS932"
Joyous Jay

Odpowiedzi podobne do “Dołącz do komputera do domeny PowerShell Script”

Pytania podobne do “Dołącz do komputera do domeny PowerShell Script”

Więcej pokrewnych odpowiedzi na “Dołącz do komputera do domeny PowerShell Script” w Shell/Bash

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu