powershell - Creating files at PSModulePath in batch -
i trying write batch program installs module named setconsolepath.psm1 @ correct location. beginner batch , have absolutely no powershell experience.
through internet, have learned how display psmodulepath powershell -command "echo $env:psmodulepath.
how can i, via .bat file, move setconsolepath.psm1 desktop location displayed powershell -command "echo $env:psmodulepath?
thank in advance, , apologize lack of experience.
before answer, must out not want copy powershell module files directly path pointed psmodulepath. want create folder inside psmodulepath , copy files there instead.
the prefix env in powershell variable indicates environment variable. $env:psmodulepath referring psmodulepath environment variable. on command line, , in batch files, environment variables can displayed placing name between percent symbols. (in fact, have displayed value typing echo %psmodulepath% instead.)
to reference desktop folder, have @ this answer, shows how use environment variable, userprofile.
therefore, copy file desktop directory path specified in psmodulepath, this:
copy "%userprofile%\desktop\setconsolepath.psm1" "%psmodulepath%" and, warned earlier, should copy file folder underneath psmodulepath. want is:
if not exist "%psmodulepath%\mynewfolder" mkdir "%psmodulepath%\mynewfolder" copy "%userprofile%\desktop\setconsolepath.psm1" "%psmodulepath%\mynewfolder"
Comments
Post a Comment