Follow sqlserver-dba.com

Subscribe to RSS feed  Follow @jackvamvas - Twitter

*Use the Comments section for questions

SQLServer-DBA.com Links

Dba_db2_button

dba-ninja.com

SQL Server DBA Jobs

How to find the working directory during runtime with Powershell Get-Location

19 July,2012 by Tom Collins

Question: I’d like to view the working directory on the powershell command line, like the pwd in Linux ? I’m experiencing problems when  moving from drive to drive in the scripts , but not finding the location. 

The other problem is to get the current directory during run-time and use in scripts.What cmdlet can I use to solve the above problems?

Answer: Use the Get-Location cmdlet.  

(Get-Location -PSProvider FileSystem).ProviderPath	

 

Add Get-Location to a variable and use it in the script. A typical use may be to display the information to a user or to move files.

Some good examples of Powershell Get-location are in these scripts.

Powershell Get-EventLog and Event Log messages

Powershell , Excel charts and data presentation

Powershell to HTML


Author: Tom Collins (http://www.sqlserver-dba.com)


Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on How to find the working directory during runtime with Powershell Get-Location


sqlserver-dba.com | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer