Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 如何使在函数中创建的PSDrive可从此函数访问?_.net_Powershell - Fatal编程技术网

.net 如何使在函数中创建的PSDrive可从此函数访问?

.net 如何使在函数中创建的PSDrive可从此函数访问?,.net,powershell,.net,Powershell,我假设在一个函数中创建一个新的PS驱动器使该驱动器只能在该函数中访问 如何使通过从主函数调用函数创建的PS驱动器可从该函数中访问 $temproraryPSDriveName = "temproraryDrive" Create-PSDriveBy $temproraryPSDriveName #private function simply creates PSDrive based on a logic dir $($temproraryPSDriveName + ":") #Thi

我假设在一个函数中创建一个新的PS驱动器使该驱动器只能在该函数中访问

如何使通过从主函数调用函数创建的PS驱动器可从该函数中访问

 $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

为您的PSDRIVE提供全局范围:

New-PSDrive -Name qq -PSProvider filesystem -Root c:\windows -Scope global