Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Searching AD

$
0
0

need a little help I finished my script to retrieve BL key. what I would like it to do now is search AD and just retrieve all key with no interaction needed. but for some reason I cant get it to do that. no errors, it just starts and stops with no result ( the way I have it now).

 

#Get Bitlocker Keys - done

 

 

$skyzone="OU=........"

 

#$computer = Read-Host 'Enter in machine name'

 

$results+=ForEach($computerin$computerObject){

 

 

$computerObject=Get-ADComputer-SearchBase$skyzone-Filter {cn-eq$computer} -PropertymsTPM-OwnerInformation,msTPM-TpmInformationForComputer,Name

if($computerObject-eq$null){

    Write-Host"Computer object not found.  Exiting the script..."

    Cmd/cpause

       Exit

}

 

 

$BitLockerObject=Get-ADObject-Filter {objectclass-eq'msFVE-RecoveryInformation'} -SearchBase$computerObject.DistinguishedName -Properties'msFVE-RecoveryPassword'|Select-Object-Last1

if($BitLockerObject.'msFVE-RecoveryPassword'){

    $BitLockerRecoveryKey=$BitLockerObject.'msFVE-RecoveryPassword'

}else{

    $BitLockerRecoveryKey='<not set>'}

 

 

New-Object-TypeNamepsobject-Property @{

        'ComputerName'=$computerObject.Name

        'Bitlocker'=$BitLockerRecoveryKey

    }

 

}

 

Write-Output=$results|Format-Table-Wrap  ComputerName,Bitlocker#|Out-File C:\Temp\results.txt

 

 

 

 

 

 

 

 

 

 

 

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles