我假设在一个函数中创建一个新的PS-Drive使得该驱动只能在该函数中访问。
如何通过调用MAIN中可以访问该函数的函数来创建PS-Drive?
$temproraryPSDriveName = "temproraryDrive"
Create-PSDriveBy $temproraryPSDriveName #private function simply creates PSDrive based on a logic
dir $($temproraryPSDriveName + ":") #This does not work as the 'teproraryDrive' is not
#accessible once I exit the Create-PSDriveBy function
答案 0 :(得分:5)
为您的PSDRIVE提供全局范围:
New-PSDrive -Name qq -PSProvider filesystem -Root c:\windows -Scope global