Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 643
  • Last Modified:

Use PowerShell Variables

Hello everyone.  This is a pretty basic question, but I am new to Powershell for the most part and have been struggling..  I am trying to utilize some of the environment variables to draft a automated task.  For example I would like to create a "testing" folder within all user profiles.

So when I run the Get-ChildItem Env: command, I see that "USERPROFILE" is listed as an evironment variable.  Great!  Just like a Command Prompt/DOS script right?  Wrong.  when I run this command:

PS c:\Users\UserName> md %USERPROFILE%\testing

It creates a folder like this:
c:\Users\UserName\%USERPROFILE%\testing

Well that isn't what I wanted....  Hmm.  What am I missing here in the PowerShell world?
0
4roi
Asked:
4roi
1 Solution
 
XaelianCommented:
Try this:

$Path =  "$env:Userprofile\Testing" 
New-Item $Path -type directory
0
 
4roiAuthor Commented:
Yep, That takes care of the immediate need.  It should also put me in the right direction for other commands.  Thank you!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now