Skip to content

Commit

Permalink
Fix online check in Remove-FileSystemObject
Browse files Browse the repository at this point in the history
  • Loading branch information
Karneades committed Apr 2, 2019
1 parent 78f78d8 commit f4e92bb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions functions/File.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ Function Remove-FileSystemObject()
[string] $Path,
[switch] $Recurse,
[string] $Regex,
[switch] $File
[switch] $File,

[boolean] $OnlineCheck = $false
)

$Function = $MyInvocation.MyCommand
Expand All @@ -133,6 +135,7 @@ Function Remove-FileSystemObject()
$WhatIfPassed = ($PSBoundParameters.ContainsKey('whatif') -and $PSBoundParameters['whatif'])

$Arguments = "Path: $Path, File: $File, Recurse: $Recurse, Regex: $Regex, WhatIfPassed: $WhatIfPassed"
$Arguments += ", Onlinecheck: $OnlineCheck"

if (!($Path))
{
Expand All @@ -150,7 +153,9 @@ Function Remove-FileSystemObject()

Write-Progress -Activity "Running $Function" -Status "Processing $Path with regex `"$Regex`" on $target..."

if (!(Test-Connection $target -Quiet -Count 1))
$IsLocalhost = ($target -match "localhost")

if (!$IsLocalhost -and $OnlineCheck -and !(Test-Connection $target -Quiet -Count 1))
{
Write-Verbose "$target is offline"
$Status = "fail"
Expand Down

0 comments on commit f4e92bb

Please sign in to comment.