我正在尝试每天在服务器上自动构建文件夹结构。该脚本有效,但由于某种原因,它在我的桌面而不是服务器上构建它。
#get date info
$ymd = Get-Date -Format yyyy_MM_dd
#name server paths
$x = '\\server\x'
#build out the internal retouch structures for the projects
'folder1', 'folder2', 'folder3\a', 'folder3\b' | % {New-Item -Name "$x\$ymd\$_" -ItemType 'Directory'}
即使我键入服务器路径,它也会在我的桌面上构建它:
#get date info
$ymd = Get-Date -Format yyyy_MM_dd
#name server paths
$x = '\\server\x'
#build out the internal retouch structures for the projects
'folder1', 'folder2', 'folder3\a', 'folder3\b' | % {New-Item -Name "\\server\x\$ymd\$_" -ItemType 'Directory'}
它正在建造的道路不是\\server\x\$ymd\...
它C:\Users\username\Desktop\server\x\$ymd\...
如果我在 ISE 中运行它或右键单击并使用 powershell 运行,就会发生这种情况。我如何告诉它从字面上使用服务器路径而不是在本地环境中构建它?我每天访问服务器并在服务器上使用 powershell 都没有问题,我以前没有尝试过像这样制作文件夹结构,所以我假设我忽略了代码中的一些简单内容。