I wrote a script that is supposed to have several parameters needed in order to create and assign folder access.
The script looks like this:
script.ps1 -FullPath "\\unc\path with\spaces\" -Maingroup "String with space" -Subgroup "string.number" -Users user1,user2,user3
Where -Fullpath is a string with UNC path and spaces
-Maingroup is a string with spaces
and -Users is an array that contains at least 1 value (but can contain more)
I define the parameters like this:
Param([string]$FullPath, [string]$MainGroup, [string]$SubGroup, [string[]]$Users)
However, when I try to run it, I tried two ways and both gave me different errors:
powershell.exe "c:\scripts\powershell\script.ps1" -FullPath "\\unc\path with\spaces\" -Maingroup "String with space" -Subgroup "string.number" -Users user1,user2,user3
(it errors out saying that there there is a missing terminator ")
powershell.exe -file "c:\scripts\powershell\script.ps1" -FullPath "\\unc\path with\spaces\" -Maingroup "String with space" -Subgroup "string.number" -Users user1,user2,user3
(it errors out saying that object 'String' (from String with space) is invalid. This means it seems to take the unc path properly but it cannot handle the "String with space" properly).
Any insights on how to solve this?
Thanks.