Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Requires -Version 4.0
- <#
- Written by David Ott
- This script will document your provisioning server environment, and send it to you via email. It was developed using PVS 7.12.
- Requires powershell version 4 (3 might work) and the PVS module. More info on the PVS module and commands in the pdf below.
- https://docs.citrix.com/content/dam/docs/en-us/provisioning-services/7-12/downloads/PvsSnapInCommands_7_12.pdf
- Look for lines marked with #### for important notes, and or areas where you need to edit this script for your environment.
- #>
- Function Set-AlternatingRows {
- [CmdletBinding()]
- Param(
- [Parameter(Mandatory,ValueFromPipeline)]
- [string]$Line,
- [Parameter(Mandatory)]
- [string]$CSSEvenClass,
- [Parameter(Mandatory)]
- [string]$CSSOddClass
- )
- Begin {
- $ClassName = $CSSEvenClass
- }
- Process {
- If ($Line.Contains("<tr><td>"))
- { $Line = $Line.Replace("<tr>","<tr class=""$ClassName"">")
- If ($ClassName -eq $CSSEvenClass)
- { $ClassName = $CSSOddClass
- }
- Else
- { $ClassName = $CSSEvenClass
- }
- }
- Return $Line
- }
- }
- $a = @"
- <style>
- TABLE {border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;width: 95%}
- TH {border-width: 1px;padding: 3px;border-style: solid;border-color: black;background-color: #6495ED;}
- TD {border-width: 1px;padding: 3px;border-style: solid;border-color: black;}
- .odd { background-color:#ffffff; }
- .even { background-color:#dddddd; }
- </style>
- "@
- ipmo 'C:\Program Files\Citrix\Provisioning Services Console\Citrix.PVS.SnapIn.dll'
- #### stops script if the pvs module is not detected
- if (!(gmo).name -contains "Citrix.PVS.Snapin") {
- Write-Host "Script requires Citrix.PVS.Snapin"
- break
- }
- $date = Get-Date -F "MM-dd-yyyy_HH-mm-ss"
- $smtpserver = "your smtp server here" #### fqdn or ip address of a smtp server
- $emails = "your email here" #### if multiple "email1.company.com","email2.company.com","email3.company.com"
- $from = "pvs@report.com" #### from address - usually not important
- $subject = "PVS Report $date" #### subject of the email
- $PVS = Get-PvsServerInfo | select @{n='PVS Server';e={$_.ServerName}},@{n='Status';e={if ($_.active -eq 1){"Active"} else {"Inactive"}}},@{n='Connected Devices';e={$_.DeviceCount}} | ConvertTo-Html -Head $a -PreContent "<center><h1>PVS Report</h1></center>"| Set-AlternatingRows -CSSEvenClass even -CSSOddClass odd
- $vdisks = Get-PvsDiskInfo | select @{n="vDisk";e={$_.disklocatorname}},@{n="Active Devices";e={$_.devicecount}},@{n='High Availability';e={$_.haenabled}},@{n="Write Cache Type";e={if ($_.writecachetype -eq "0") {"Private/Maint"} elseif ($_.writecachetype -eq "7") {"Cache to PVS Server Persistent"} elseif ($_.writecachetype -eq "1") {"Cache to PVS Server"}`
- elseif ($_.writecachetype -eq "3") {"Cache to Device RAM"} elseif ($_.writecachetype -eq "8") {"Cache to Device Hard Disk Persistent"} elseif ($_.writecachetype -eq "9") {"Cache to RAM with Overflow to Disk"}`
- elseif ($_.writecachetype -eq "4") {"Cache on HDD"}}} | ConvertTo-Html | Set-AlternatingRows -CSSEvenClass even -CSSOddClass odd
- $vdiskstart = $vdisks.IndexOf("<table>")
- $vdiskend = $vdisks.IndexOf("</table>")
- $vdisks = ($vdisks | select -Index ($vdiskstart..$vdiskend))+"<br><br>"
- $versions = Get-PvsDiskInfo | select disklocatorid,disklocatorname | %{
- $diskname = $_.DiskLocatorName
- Get-PvsDiskVersion -DiskLocatorId $_.DiskLocatorId | select @{n='Disk Name';e={$diskname}},Version,@{n="Disk Status";e={if ($_.goodinventorystatus -eq $false -and $_.access -ne "1") {"Not Synced"} elseif ($_.access -ne "1") {"Synced"} elseif ($_.access -eq "1") {"Read/Write"}}}
- } | ConvertTo-Html | Set-AlternatingRows -CSSEvenClass even -CSSOddClass odd
- $versionstart = $versions.IndexOf("<table>")
- $versionend = $versions.IndexOf("</table>")
- $versions = ($versions | select -Index($versionstart..$versionend))+"<br><br>"
- $farm = Get-PvsFarm | select @{n='Farm Name';e={$_.FarmName}},@{n='License Server';e={$_.licenseserver}},@{n='Database Server Name';e={$_.databaseservername}},`
- @{n='Database Name';e={$_.databasename}},@{n='Offline DB Enabled';e={$_.offlinedatabasesupportenabled}} | ConvertTo-Html | Set-AlternatingRows -CSSEvenClass even -CSSOddClass odd
- $farmstart = $farm.IndexOf("<table>")
- $farmend = $farm.IndexOf("</table>")
- $farm = $farm | select -Index($farmstart..$farmend)
- $join = $vdisks+$versions+$farm
- $insert = $pvs.IndexOf("</table>")-1
- $message = ($pvs -split "\<\/table\>")[0..$insert]+"</table>"+"<br><br>"+$join+"</body></html>"
- Send-MailMessage -From $from -To $emails -Subject $subject -Body "$message" -BodyAsHtml -SmtpServer $smtpserver #### sends the report in an email
- #### And/or uncommment the line below, and adjust the path to create an html file
- #$message | Out-File \\server\share\pvs_report_$date.html
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement