Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Creating a folder if it doesn't exist

$
0
0

I am trying to write a powershell script that will create a folder called temp in c:\ if the folder doesn't already exist. It will then copy the file to the folder. Below is what I have so far:

$Servers = Get-Content '\\share\computers.txt

$Hotfixpath = '\\share\hotfix\hotfix.msi

foreach ($Server in $Servers){

    if (!(Test-Path -path "\\$Server\c$\temp")){

         New-Item "\\$Server\c$\temp" -type directory

         Write-Host "Processing $Server..."

         Copy-Item $Hotfix \\$Server\C$\temp


Viewing all articles
Browse latest Browse all 6937

Trending Articles