Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make a PSDrive created within a function accessible out of this function?

I assume creating a new PS-Drive within a function makes that drive only accessible within that function.

How can I make a PS-Drive created by calling a function from the MAIN accessible out of that function?

 $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
like image 856
pencilCake Avatar asked May 21 '13 08:05

pencilCake


People also ask

What can be used to create a new PSDrive for desktop in PowerShell?

You can use the Persist parameter of New-PSDrive to create Windows mapped network drives. Unlike temporary PowerShell drives, Windows mapped network drives aren't session-specific. They're saved in Windows and they can be managed by using standard Windows tools, such as File Explorer and net use.

What is a PS drive?

If you're using PowerShell to work with a file system, registry, certificates, or even network drives, you've got to check out PowerShell drives. PowerShell drives or PS drives are a concept in PowerShell that allows you to work with structured data like a file system. The New PSDrive cmdlet is the way to begin.

What are PowerShell drives?

A Windows PowerShell drive is a data store location that you can access like a file system drive in Windows PowerShell.

How do I uninstall PSDrive?

The Remove-PSDrive cmdlet deletes temporary PowerShell drives that were created by using the New-PSDrive cmdlet. Beginning in Windows PowerShell 3.0, Remove-PSDrive also disconnects mapped network drives, including, but not limited to, drives created by using the Persist parameter of New-PSDrive .


1 Answers

Give global scope to your PSDRIVE:

New-PSDrive -Name qq -PSProvider filesystem -Root c:\windows -Scope global
like image 146
CB. Avatar answered Sep 28 '22 10:09

CB.