One of those banging your head one the wall problems today, with trying to run a PS script that I needed to supply the full path and where the path had spaces.
PS C:\>C:\My Scripts\My PowerShell.ps1
Now I knew that wouldn't work, but tried it anyway. Get the error
The term 'C:\My' is not recognized as the name of a cmdlet, function, script file, or operable program.
So I think, ok, let's wrap in quotes. That'll work
PS C:\>"C:\My Scripts\My PowerShell.ps1"
But nothing. No error, no nothing...hmmm
Some Googling later, as with PS scripts that don't need a space, you need to pre-fix with .\, if they are wrapped in quotes, you need to prefix with '&' (obviously). I expect it is obvious to those that work in PS all the time, but I don't...
So the command I was really looking for is
PS C:\>& "C:\My Scripts\My PowerShell.ps1"
No comments:
Post a Comment