Created
November 21, 2016 16:27
-
-
Save anonymous/93c9fa41bef0253096bc08bf9518e301 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#psm1 file: | |
Function remove-OldFiles{ | |
Param( | |
[int] $DaystoRemove, | |
[string[]] $ExcludeFolders, | |
[string] $Path | |
) | |
if(Test-Path($Path)){ | |
foreach($ExcludeFolder in $ExcludeFolders){ | |
if(Test-Path($Path+$ExcludeFolder)){ | |
}else{ | |
Write-Host "$ExcludeFolder was not found on the Path $Path" | |
break | |
} | |
} | |
$SubFolders = gci -Recurse -Path $Path -Filter $ExlcudeFolders | |
}else{ | |
Write-Host "Specified path $Path not found" | |
} | |
}export-moduleMember -Function remove-OldFiles | |
#ps1 file: | |
Import-Module "D:\Coding\PowerShell\Modules\remove-OldFiles.psm1" | |
remove-OldFiles -Path 'D:\Coding' -ExcludeFolders "Bootstrap Learning","PowerShell","Waaah!" | |
#the folder Waaah! dont exists in the Folder mentioned above. so in the PSM there is a write-Host line to display this error. but i dont see it when i call the function from the ps1 script. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment