I got the following error while executing my powershell script.
Cannot overwrite variable host because it is read-only or constant.
At line:1 char:1
~~~~~~~~~~~~~~~~~- CategoryInfo : WriteError: (host:String) [], SessionStateUnauthorizedAccessException
- FullyQualifiedErrorId : VariableNotWritable
$host is a reserved word in powershell. So it worked after replacing $host with $hostname