![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | How to access the %temp% directory using PowerShell I need to be able to access some files in the %temp% directory on the computer and I am unable to open that directory in PowerShell. If I open a cmd.exe window, I can simple type cd %temp% and it opens just fine. Is there any reason why PowerShell would have issues with this? Thanks, -Flea# -- http://fleasharp.blogspot.com/ |
My System Specs![]() |
| | #2 (permalink) |
| | Re: How to access the %temp% directory using PowerShell PowerShell keeps environemnt variables in a special PSDrive called: env To get all environment variables, type: dir env: To get a specific variable, type: $env:<variableName>, as in: get-childitem $env:temp ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Quote: > I need to be able to access some files in the %temp% directory on the > computer and I am unable to open that directory in PowerShell. If I > open a cmd.exe window, I can simple type cd %temp% and it opens just > fine. Is there any reason why PowerShell would have issues with this? > > Thanks, > -Flea# |
My System Specs![]() |
| | #3 (permalink) |
| | Re: How to access the %temp% directory using PowerShell $env:temp -- Kiron |
My System Specs![]() |
| | #4 (permalink) |
| | Re: How to access the %temp% directory using PowerShell $env:Temp More Info: Get-help about_Environment_Variable Brandon Shell --------------- Blog: http://www.bsonposh.com/ PSH Scripts Project: www.codeplex.com/psobject F> I need to be able to access some files in the %temp% directory on the F> computer and I am unable to open that directory in PowerShell. If I F> open a cmd.exe window, I can simple type cd %temp% and it opens just F> fine. Is there any reason why PowerShell would have issues with F> this? F> F> Thanks, F> -Flea# |
My System Specs![]() |
| | #5 (permalink) |
| | Re: How to access the %temp% directory using PowerShell Flea# wrote: Quote: > I need to be able to access some files in the %temp% directory on the > computer and I am unable to open that directory in PowerShell. If I open a > cmd.exe window, I can simple type cd %temp% and it opens just fine. Is there > any reason why PowerShell would have issues with this? > > Thanks, > -Flea# > PSH>$env:temp C:\DOCUME~1\foo\LOCALS~1\Temp Marco -- Microsoft MVP - Windows PowerShell http://www.microsoft.com/mvp PowerGadgets MVP http://www.powergadgets.com/mvp Blog: http://marcoshaw.blogspot.com |
My System Specs![]() |
| | #6 (permalink) |
| | Re: How to access the %temp% directory using PowerShell And the Winner is ... ![]() three answers in seconds.... love it! Brandon Shell --------------- Blog: http://www.bsonposh.com/ PSH Scripts Project: www.codeplex.com/psobject M> Flea# wrote: M> Quote: Quote: >> I need to be able to access some files in the %temp% directory on the >> computer and I am unable to open that directory in PowerShell. If I >> open a cmd.exe window, I can simple type cd %temp% and it opens just >> fine. Is there any reason why PowerShell would have issues with >> this? >> >> Thanks, >> -Flea# M> PSH>> $env:temp PSH>> M> C:\DOCUME~1\foo\LOCALS~1\Temp M> M> Marco M> M> PowerGadgets MVP M> http://www.powergadgets.com/mvp M> Blog: M> http://marcoshaw.blogspot.com |
My System Specs![]() |
| | #7 (permalink) |
| | Re: How to access the %temp% directory using PowerShell Quote: > three answers in seconds.... love it! |
My System Specs![]() |
| | #8 (permalink) |
| | Re: How to access the %temp% directory using PowerShell Kiron, Brandon, Marco, Shay, Thanks for all your fast replies! I am new to powershell so your expertise is invaluable to me. Your examples worked perfect for me and now I know about the env variables. I do have two questions for you all though. 1. I am going to be needing to do a lot of work with PowerShell on remote machines. PowerShell seems great when running stuff locally but I am finding trouble trying to take what is simple locally and then applying it to remote machines. Is there some way to create an object of a remote machine so that whatever I execute can be ran against the remote machine? 2. For this example of the env variables, is it possible to access the env variable of a remote machine? Basically there are files that I need to copy from the %temp% directory of a given server and while the command $env:temp is great for my machine, I don't know how to apply it to a remote machine. Thanks to all for your advice and assistance! -Flea# -- http://fleasharp.blogspot.com/ "Shay Levi" wrote: Quote: > > PowerShell keeps environemnt variables in a special PSDrive called: env > > To get all environment variables, type: > > dir env: > > To get a specific variable, type: > > $env:<variableName>, as in: > > get-childitem $env:temp > > > > ----- > Shay Levi > $cript Fanatic > http://scriptolog.blogspot.com > Quote: > > I need to be able to access some files in the %temp% directory on the > > computer and I am unable to open that directory in PowerShell. If I > > open a cmd.exe window, I can simple type cd %temp% and it opens just > > fine. Is there any reason why PowerShell would have issues with this? > > > > Thanks, > > -Flea# > > |
My System Specs![]() |
| | #9 (permalink) |
| | Re: How to access the %temp% directory using PowerShell 1) not until v2 (which is a long way off.) You can do alot with WMI and .NET though. Just need an idea of what your trying to do. 2) You can find this info in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment which you can access via a .NET object. Here is an example $srv = "Computer" $regKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine, $Srv) $key = $regKey.OpenSubkey("SYSTEM\CurrentControlSet\Control\Session Manager\Environment",$true) $key.GetValueNames() | Select-Object @{n="ValueName";e={$_}},@{n="Value";e={$key.GetValue($_)}} Brandon Shell --------------- Blog: http://www.bsonposh.com/ PSH Scripts Project: www.codeplex.com/psobject F> Kiron, Brandon, Marco, Shay, F> F> Thanks for all your fast replies! I am new to powershell so your F> expertise is invaluable to me. F> F> Your examples worked perfect for me and now I know about the env F> variables. I do have two questions for you all though. F> F> 1. I am going to be needing to do a lot of work with PowerShell on F> remote machines. PowerShell seems great when running stuff locally F> but I am finding trouble trying to take what is simple locally and F> then applying it to remote machines. Is there some way to create an F> object of a remote machine so that whatever I execute can be ran F> against the remote machine? F> F> 2. For this example of the env variables, is it possible to access F> the env variable of a remote machine? Basically there are files that F> I need to copy from the %temp% directory of a given server and while F> the command $env:temp is great for my machine, I don't know how to F> apply it to a remote machine. F> F> Thanks to all for your advice and assistance! F> F> -Flea# F> F> "Shay Levi" wrote: F> Quote: Quote: >> PowerShell keeps environemnt variables in a special PSDrive called: >> env >> >> To get all environment variables, type: >> >> dir env: >> >> To get a specific variable, type: >> >> $env:<variableName>, as in: >> >> get-childitem $env:temp >> >> ----- >> Shay Levi >> $cript Fanatic >> http://scriptolog.blogspot.com Quote: >>> I need to be able to access some files in the %temp% directory on >>> the computer and I am unable to open that directory in PowerShell. >>> If I open a cmd.exe window, I can simple type cd %temp% and it opens >>> just fine. Is there any reason why PowerShell would have issues >>> with this? >>> >>> Thanks, >>> -Flea# |
My System Specs![]() |
| | #10 (permalink) |
| | Re: How to access the %temp% directory using PowerShell Keep in mind that (locally) $env:temp (%temp%) is the path to a USER temp directory, not the server's. If you want to get the system's temp path: PS > [environment]::GetEnvironmentVariable("temp","machine") C:\WINDOWS\TEMP ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Quote: > Kiron, Brandon, Marco, Shay, > > Thanks for all your fast replies! I am new to powershell so your > expertise is invaluable to me. > > Your examples worked perfect for me and now I know about the env > variables. I do have two questions for you all though. > > 1. I am going to be needing to do a lot of work with PowerShell on > remote machines. PowerShell seems great when running stuff locally but > I am finding trouble trying to take what is simple locally and then > applying it to remote machines. Is there some way to create an object > of a remote machine so that whatever I execute can be ran against the > remote machine? > > 2. For this example of the env variables, is it possible to access > the env variable of a remote machine? Basically there are files that > I need to copy from the %temp% directory of a given server and while > the command $env:temp is great for my machine, I don't know how to > apply it to a remote machine. > > Thanks to all for your advice and assistance! > > -Flea# > > "Shay Levi" wrote: > Quote: >> PowerShell keeps environemnt variables in a special PSDrive called: >> env >> >> To get all environment variables, type: >> >> dir env: >> >> To get a specific variable, type: >> >> $env:<variableName>, as in: >> >> get-childitem $env:temp >> >> ----- >> Shay Levi >> $cript Fanatic >> http://scriptolog.blogspot.com Quote: >>> I need to be able to access some files in the %temp% directory on >>> the computer and I am unable to open that directory in PowerShell. >>> If I open a cmd.exe window, I can simple type cd %temp% and it opens >>> just fine. Is there any reason why PowerShell would have issues >>> with this? >>> >>> Thanks, >>> -Flea# |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Access Active directory with sql server in powershell | PowerShell | |||
| Clean Temp Directory? | .NET General | |||
| Windowc temp directory | Vista file management | |||
| LPKSetup Log Files in TEMP directory | Vista performance & maintenance | |||
| Temp Directory acts like media directory | Vista General | |||