Скрипт Powershell не завершается
Я пытаюсь запустить вывод скрипта Powershell в формате HTML через Bladelogic
Сценарий работает, но не выходит
[cmdletbinding()]
param
(
[Parameter(Position=0,ValuefromPipeline=$true)]
[string[]]$ComputerName = $env:ComputerName
)
$cpuload = ((Get-Counter -Counter "\\$ComputerName\Process(*)\% Processor Time" -ea 0).CounterSamples) | Select-Object -Property instancename, cookedvalue | Sort-Object -Property cookedvalue -Descending | Select-Object -First 20 |Select-Object InstanceName,@{L='CPU';E={($_.Cookedvalue/100).toString('P')}}
$a = "<style>"
$a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
$a = $a + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;}"
$a = $a + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;}"
$a = $a + "</style>"
$cpuload | ConvertTo-Html -head $a -body "<H2>CPU LOAD</H2>" | Out-File -FilePath C:\tmp\dis.txt
#Invoke-Expression C:\tmp\dis1.txt
#cat C:\tmp\dis1.txt
Get-Content 'C:\tmp\dis.txt' | Foreach-Object {$_ -replace '^<html.*$', ("<html>")} | Set-Content 'C:\tmp\dis1.txt'
cat C:\tmp\dis1.txt