We are trying to get the remediation to run in Intune to bitlocker and upload the numerical key to Azure. When I connect to a non encrypted machine and run the following manually this works 100% of the time. I do run each line and wait till it finishes to run the next. When I try to run this in PS ISE and put a sleep timer of 15 seconds between steps 1-2 and steps 2-3 the second line fails and returns the following...ERROR: Invalid Syntax.
"?protectors" was not understood.
Why would this work manually but not automatically and fail with that error?
Enable-BitLocker -MountPoint "C" -EncryptionMethod XtsAes128 -UsedSpaceOnly -TpmProtector -SkipHardwareTest
manage-bde –protectors –add C: -RecoveryPassword
BackupToAAD-BitLockerKeyProtector -MountPoint $env:SystemDrive -KeyProtectorId ((Get-BitLockerVolume -MountPoint $env:SystemDrive...