none
PowerShell Script to create a folder and save output RRS feed

  • Question

  • Hi Everyone,

    I am trying to achieve following solution, any help will be much appreciated.

    I have a Powershell script which creates an output and I am enable to export it to user desktop or other places on C drive.  I can export to network drive too by simply providing network drive address. I would like to save my out on a folder, if that folder doesn't exist the script will create the folder and if the folder does exist then simple save output files on that folder.

    Many Thanks in Advance

    Monday, December 19, 2016 12:15 PM

Answers

  • $path = "C:\temp\NewFolder"
    If(!(test-path $path))
    {
    New-Item -ItemType -type Directory -Force -Path $path
    }

    This will create the follder if it does not exist, to continue use $path in your copy or move statement to put the file there. $path is hard coded in this example but you could pass a parameter.
    • Marked as answer by uzeshan Wednesday, December 21, 2016 12:27 PM
    Monday, December 19, 2016 3:00 PM

All replies

  • So what's your question? You already have a script and you're able to export everything. If you have problöems with your script you can post it here and the error if you have one and we'll try to help.

    Grüße - Best regards

    PS:> (79,108,97,102|%{[char]$_})-join''

    Monday, December 19, 2016 2:33 PM
  • $path = "C:\temp\NewFolder"
    If(!(test-path $path))
    {
    New-Item -ItemType -type Directory -Force -Path $path
    }

    This will create the follder if it does not exist, to continue use $path in your copy or move statement to put the file there. $path is hard coded in this example but you could pass a parameter.
    • Marked as answer by uzeshan Wednesday, December 21, 2016 12:27 PM
    Monday, December 19, 2016 3:00 PM