52 lines
1.7 KiB
PowerShell
52 lines
1.7 KiB
PowerShell
clear
|
|
|
|
. $PSScriptRoot\Get-HackerText.ps1
|
|
. $PSScriptRoot\Invoke-ScriptedActions.ps1
|
|
. $PSScriptRoot\Register-AlkamiVolume.ps1
|
|
. $PSScriptRoot\Unregister-AlkamiVolume.ps1
|
|
. $PSScriptRoot\Connect-AlkamiVolume.ps1
|
|
. $PSScriptRoot\Disconnect-AlkamiVolume.ps1
|
|
. $PSScriptRoot\scratch.ps1
|
|
|
|
$profileName = 'temp-dev'
|
|
|
|
$PromptText = ((prompt | Out-String) -replace "`n", '' -replace "`r", '')
|
|
$verbs = (Get-Verb).Verb | Sort-Object
|
|
|
|
$text = Get-Content $PSScriptRoot\demo.ps1
|
|
|
|
foreach ($line in $text) {
|
|
if ([string]::IsNullOrWhiteSpace($line)) {
|
|
Write-Host $PromptText
|
|
continue
|
|
}
|
|
if ($line.Trim()[0] -eq '#') {
|
|
Write-Host -NoNewLine $PromptText
|
|
Write-Host -ForegroundColor DarkGreen $line.Trim()
|
|
continue
|
|
}
|
|
$maybeVerb = ($line -split '-')[0].Trim()
|
|
$actions = Get-HackerText -Textline $line
|
|
Invoke-ScriptedActions -Actions $actions
|
|
|
|
if ($maybeVerb -in $verbs) {
|
|
# execute the line maybe?
|
|
try {
|
|
Invoke-Expression "$line"
|
|
} catch {
|
|
Write-Host -ForegroundColor Red -BackgroundColor Black $_
|
|
Write-Host -ForegroundColor Red -BackgroundColor Black $_.Exception
|
|
}
|
|
} else {
|
|
$firstWord = ($line -split ' ')[0]
|
|
Write-Host -ForegroundColor Red -BackgroundColor Black @"
|
|
$firstWord : The term '$firstWord' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
|
|
At line:1 char:1
|
|
+ $line
|
|
+ ~~~~
|
|
+ CategoryInfo : ObjectNotFound: ($firstWord:String) [], ParentContainsErrorRecordException
|
|
+ FullyQualifiedErrorId : CommandNotFoundException
|
|
"@
|
|
}
|
|
}
|