cls
$InAccount = Read-Host -Prompt 'Ange AD konto'
$aduser = $null
$ErrorActionPreference = "Silentlycontinue"
Write-host "analyserar." -NoNewline
$aduser = get-aduser $InAccount -Properties GivenName,Surname,Title,trv-GeneralID,SID,AccountExpirationDate,whenCreated,streetaddress,City,MobilePhone,PasswordExpired,PasswordLastSet,LastBadPasswordAttempt,PasswordNotRequired,Enabled,Department,isDeleted,LockedOut,mail,trv-OtpDevicePhoneNumber,name,SamaccountName,description | select GivenName,Surname,Department,Title,name,trv-GeneralID,SID,Enabled,SamaccountName,AccountExpirationDate,whenCreated,streetaddress,City,MobilePhone,trv-OtpDevicePhoneNumber,PasswordExpired,PasswordLastSet,LastBadPasswordAttempt,PasswordNotRequired,isDeleted,LockedOut,mail,description
if($aduser -ne $null)
{
Write-host "." -NoNewline
$addist = get-aduser $InAccount -Properties DistinguishedName | select -ExpandProperty DistinguishedName
$admanager = get-aduser $InAccount -Properties manager | select -ExpandProperty manager | get-aduser -Properties GivenName,Surname,Department,mobilephone,mail,SamAccountName | select GivenName,Surname,Department,mobilephone,mail,SamAccountName
Write-host "."
$adgroups = get-aduser $InAccount -Properties memberof | select -ExpandProperty memberof | get-adgroup -Properties name | select -ExpandProperty name
write-host
write-host "Konto information:" -NoNewline
$aduser
write-host
write-host "Chefinformation:"
write-host
$admanager
write-host
write-host "Behörigheter:"
write-host
$adgroups
write-host
write-host "Söker hanterade datorer:"
Get-ADComputer -filter * -SearchBase "OU=Clients,DC=domain,DC=nu" -Properties managedby | where {$_.managedby -eq $addist}
}
else
{
write-host "`nKonto $InAccount finns inte i AD"
}