如何在可以通过此功能访问的功能中创建PSDrive?

时间:2013-05-21 08:14:50

标签: .net powershell

我假设在一个函数中创建一个新的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

1 个答案:

答案 0 :(得分:5)

为您的PSDRIVE提供全局范围:

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