“Rejoignez l'ordinateur à Domain PowerShell Script” Réponses codées

Rejoignez l'ordinateur à Domain 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

Rejoignez l'ordinateur à 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
Joyous Jay

Rejoignez l'ordinateur à Domain 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

Rejoignez l'ordinateur à Domain 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

Rejoignez l'ordinateur à Domain 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

Rejoignez l'ordinateur à Domain PowerShell Script

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

Rejoignez l'ordinateur à Domain PowerShell Script

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

Rejoignez l'ordinateur à Domain PowerShell Script

Remove-ADObject -Identity "WKS932"
Joyous Jay

Réponses similaires à “Rejoignez l'ordinateur à Domain PowerShell Script”

Questions similaires à “Rejoignez l'ordinateur à Domain PowerShell Script”

Plus de réponses similaires à “Rejoignez l'ordinateur à Domain PowerShell Script” dans Shell/Bash

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code