这个脚本应该创建一些新的驱动器,但在我运行它后,它们不存在,任何想法为什么?完全卡住了……提前感谢
Function New-Drives {
Param()
New-PSDrive -Name AppData -PSProvider FileSystem -Root $env:Appdata
New-PSDrive -Name Temp -PSProvider FileSystem -Root $env
$env:TEMP=Join-Path -Path C:WindowsTemp
$mydocs=Join-Path -Path $env:userprofile -ChildPath Documents
New-PSDrive -Name Docs -PSProvider FileSystem -Root $mydocs
}
DIR temp: | measure-object –property length -sum
New-Drives
您需要将-Persist
参数添加到New-PSDrive
调用中。否则它只会在powershell会话中创建驱动器。