-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathrun.ps1
More file actions
23 lines (18 loc) · 744 Bytes
/
run.ps1
File metadata and controls
23 lines (18 loc) · 744 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
[CmdletBinding()]
$myPath = Split-Path $script:MyInvocation.MyCommand.Path
$scriptsInOrder = Get-ChildItem ($myPath) -Directory | ForEach-Object { Get-ChildItem (($_.FullName) + "\*.ps1") -Recurse } | Where-Object {!$_.Name.StartsWith("~")} | Sort-Object
$scriptsInOrder | % {
$shortname = $_.Name.Replace(".ps1","")
$longname = $_.FullName.Replace($myPath, "")
$scriptBlock = Get-Content -Path $_ -Raw
Write-Verbose -Message ("Running file: " + $_.FullName)
if ($shortname.StartsWith("_")) {
$script = Get-Content -Path $_ -Raw
if (![String]::IsNullOrWhiteSpace($script)) {
Invoke-Expression (gc $_ -Raw)
}
} else {
& $_.FullName
}
}
Start-Sleep -Seconds 10