


If the CSV contains string values for Enabled and ChangePasswordAtLogon literally as '$true' or '$false', you need to remove the dollar sign from it to be able to convert them into real Boolean values.Īlso, I would suggest using Splatting the parameters to New-ADUser, so you can get rid of all those unneeded extra variables and especially those pesky backticks: param( $inputfile) The error:Įxception calling "ToBoolean" with "1" argument(s): "String was not recognized as a valid Boolean."Īnyone who knows the best way to resolve this issue? With the current code, my only problem (currently) seems to be I am unable to parse this string to a boolean. ChangePasswordAtLogon = $ChangePasswordAtLogon `

AccountPassword (ConvertTo-SecureString $Password -AsPlainText -Force) ` $ChangePasswordAtLogon = ::ToBoolean($User.mustChangePassword) $ADUsers = Import-csv $inputfile -Delimiter ' ' These values will only be $true or false. One of the values I need to import needs to be converted to a boolean.
#Powershell convert string to boolean how to#
I am trying to learn how to import a csv in Powershell and create users out of it.
