## get computername
cls
$wks = read-host 'The name of the computer you wish to re-image'
## Setting Firewall and remote settings
Get-ADComputer $wks | Move-ADObject -TargetPath 'OU=Geen FW,OU=Desktops,OU=Computers W7,OU=BHW,OU=company,DC=company,DC=nl'
Restart-Computer -ComputerName $wks -Force
Invoke-Command -ComputerName $wks {gpupdate}
get-service -ComputerName $wks winrm |Start-Service
## get mac address
$mac = Get-WmiObject -ComputerName $wks win32_networkadapter -Filter 'netconnectionid = "Lan-Verbinding"' | select Macaddress
## get computer memberships
$groep = Get-ADComputer $wks -Properties MemberOf | select memberof
cls
Write-Host "Computernaam: " $wks
Write-Host "Mac adres: " $mac
Write-Host "Lid van groepen: " $groep
## remove computer from domain
Remove-ADComputer $wks -Confirm
## SCCM remove computer from sccm
Enter-PSSession -ComputerName SCCMserver -ConfigurationName Microsoft.PowerShell32
Import-Module "f:Program FilesMicrosoft Configuration ManagerAdminConsolebinConfigurationManager.psd1"
#f:
#Cd
#cd '.Program FilesMicrosoft Configuration ManagerAdminConsolebin'
#Import-Module .ConfigurationManager.psd1
Cd m01:
Remove-CMDevice -DeviceName $using:wks
## SCCM add mac address to SCCM
Import-CMComputerInformation -ComputerName $using:wks -MacAddress 9C:8E:99:DB:5D:1C -CollectionName "Alle werkstations"
exit
## SCCM Wait for computer in collection alle werkstations
## Reboot computer in F12