Ok, so this one's a quickie. I was invoking some PowerShell from the command line (a batch file) that would iterate a Web Application, gather some info and generate a CSV report into a local folder.
Suddenly, there was a requirement to save these reports to a network shared location. The current solution had a variable for the location of the reports, but it wouldn't support a network path.
(...)
The batch was expecting a local folder name and changing to it
by using "cd /d %~dp0%LocalFolder%", which obviously wouldn't work with a
UNC path. The answer was using pushd & popd! Many thanks to this post for the info.
Just replace the "cd" statement with "pushd %UNCPath%" and then add "popd" in the end of your batch. Works like a charm!
And if you're thinking about PowerShell, you can use the change directory (cd) command directly, it supports UNC Paths, unlike the command line.
No comments:
Post a Comment