Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Looping Test-Path

$
0
0

I am attempting to create a looping PowerShell script for see if a folder named after a computer is created.  This is going to be used to kick off a process once the folder is created.  I cannot seem to put my finger on the logic.  Here is what I have, any help would be appreciated!!!

param($args0)
$Stoploop = $false
[int]$Retrycount = "0"
$NameToBeParsed = $args0.tostring()
$SharePath = '\\deploy.kdt.int\deploy$\logs\'
$LogPath = ($SharePath + $NameToBeParsed)
$ValidPath = Test-Path $LogPath
$ErrorActionPreference = 'Stop'

do {
	try { 
       	}
	catch {
		if ($ValidPath -eq $True) {
            Test-Path $LogPath
            Write-Output Success
            $Stoploop = $true
            }

        Else {
                If ($Retrycount -gt 3) {
			        Write-Host "Could not send Information after 3 retrys."
			        $Stoploop = $true
		        }
		        else {
			        Write-Host "Could not send Information retrying in 30 seconds..."
			        Start-Sleep -Seconds 30
			        $Retrycount = $Retrycount + 1
                    Write-Host $Retrycount
                    }
		}
	}
}
While ($Stoploop -eq $false)


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>