I am new to Solarwinds and trying to setup a powershell component monitor to monitor a bitlockers drives status but i cannot get this to produce an output. my script is below can people kindly point out my glaring errors?

$DriveLetter = "C:";
$Error.Clear();

if ( Test-Path $DriveLetter ) { }
else
 {
 Write-Host "Message: Drive Not found"
 exit 1
 }

$computer=$Env:COMPUTERNAME
$BitLockerStatus = Invoke-Command -ScriptBlock{ Get-BitLockerVolume -MountPoint "$DriveLetter" } -ComputerName $computer  -ErrorAction Stop
$BLMP = $BitLockerStatus.MountPoint
$BLLS = $BitLockerStatus.LockStatus
$BLpe = $BitLockerStatus.EncryptionPercentage

if($BitLockerStatus.LockStatus -eq 'Unlocked')
{
Write-Host "Message:" $BLLS
Write-Host "Statistic:" $BLpe
Exit 0
}
else 
{
Write-Host "Message: $BLLS"
Write-Host "Statistic: $BLpe"
Exit 1
}

Parents
  • Invoke-Command can't have the arguments passed in that way when it's sent to a remote computer.  You need to send them as an argument list.

    think it would need to go something like this:

    $BitLockerStatus = Invoke-Command -ScriptBlock { Get-BitLockerVolume -MountPoint ( $args[0] ) } -ComputerName $computer -ErrorAction Stop -ArgumentList ( $DriveLetter )

    Review the help documentation on it.

    Get-Help Invoke-Command -Online

Reply
  • Invoke-Command can't have the arguments passed in that way when it's sent to a remote computer.  You need to send them as an argument list.

    think it would need to go something like this:

    $BitLockerStatus = Invoke-Command -ScriptBlock { Get-BitLockerVolume -MountPoint ( $args[0] ) } -ComputerName $computer -ErrorAction Stop -ArgumentList ( $DriveLetter )

    Review the help documentation on it.

    Get-Help Invoke-Command -Online

Children
No Data