
我正在使用下面的 PowerShell 程式碼,該程式碼工作正常。
唯一不起作用的部分是超連結部分。雖然它工作正常並給了我輸出,但我無法在我處理程式碼的伺服器之外打開超連結。
不確定如何更改 C:\TEMP\ 位置的超連結並使其動態可存取。請建議。
代碼 :
$ok = 80
$NotOk = 90
$ser = @('Serv1','Serv2')
$Out = foreach($s in $ser){
#$Disk = Get-Content C:\temp\Disk.htm
$link = "<a href='c:\temp\disk.htm'>Disk</a> "
Get-WmiObject Win32_Volume -ComputerName $s|`
Where { $_.drivetype -eq '3' -and $_.driveletter} |`
Select-Object SystemName,driveletter,name,label,
@{Name='freespace';Expression={[Int]($_.freespace/1GB)}},
@{Name='capacity';Expression={[Int]($_.capacity/1GB)}},
@{Name='UsedSpace';Expression={"{0:N0}" -f ( $_.capacity/1GB - $_.FreeSpace/1GB )}},
@{Name='UsedSpacePercent';Expression={"{0:N0}" -f (($_.capacity - $_.FreeSpace) / $_.Capacity * 100)}} | `
Where-Object {$_.label -notlike "Recovery" -and $_.name -notlike "*volume*" -and $_.name -notlike "D:\" }}
$Out |select SystemName,DriveLetter,Capacity,usedspacepercent|`
convertto-html -Head $Header -Body " <H2 style=color:#000000;font-family:calibri;text-align:left; >Servers Disk Status $link </h2> "|
Out-File C:\Temp\DatabaseStatusReport_Test.html -Append
筆記 :超連結的檔案可以在伺服器中打開,沒有任何問題。
使用的超連結變數是$連結
下面是程式碼和錯誤訊息。
點擊“是”後,我會收到以下訊息
請幫助我如何讓它發揮作用。