i am creating a Powershell script to enable Bitlocker. For this i need a PIN which is converted to a securestring. This PIN must be randomly generated. For this i have these two options:
$pin = Get-Random -Minimum 0 - Maximum 9
and
$pin = ( (1..6) | ForEach-Object { Get-Random -Minimum 0 -Maximum 9 } ) -join ''
The first one has a problem for my usage because it generates some PINs with 5 characters but i need 6 characters for my usage
The second one does the right job for now.
As already said i need a secure-string to enable bitlocker. I've tried the ConvertTo-SecureString cmdlet
ConvertTo-SecureString -AsPlainText $pin -Force
I get the error which says:
Cannot bind argument to parameter 'String' because it is NULL.
Does someone knows how to make it work?
Btw: I am beginner with Powershell