PoshCode Archive  Hex Artifact Content

Artifact 5d8762ac43f001c98c98b6dc7954e9dc909a9a4db08ad5f50e2148d0ac87ce39:

  • File UCS_FaultReport.ps1 — part of check-in [1abd3bdb7a] at 2018-06-10 13:33:02 on branch trunk — Basic Cisco UCS fault report (user: monahancj size: 4021)

0000: 23 20 65 6e 63 6f 64 69 6e 67 3a 20 61 73 63 69  # encoding: asci
0010: 69 0d 0a 23 20 61 70 69 3a 20 70 6f 77 65 72 73  i..# api: powers
0020: 68 65 6c 6c 0d 0a 23 20 74 69 74 6c 65 3a 20 55  hell..# title: U
0030: 43 53 5f 46 61 75 6c 74 52 65 70 6f 72 74 2e 70  CS_FaultReport.p
0040: 73 31 0d 0a 23 20 64 65 73 63 72 69 70 74 69 6f  s1..# descriptio
0050: 6e 3a 20 42 61 73 69 63 20 43 69 73 63 6f 20 55  n: Basic Cisco U
0060: 43 53 20 66 61 75 6c 74 20 72 65 70 6f 72 74 0d  CS fault report.
0070: 0a 23 20 76 65 72 73 69 6f 6e 3a 20 30 2e 31 0d  .# version: 0.1.
0080: 0a 23 20 74 79 70 65 3a 20 66 75 6e 63 74 69 6f  .# type: functio
0090: 6e 0d 0a 23 20 61 75 74 68 6f 72 3a 20 6d 6f 6e  n..# author: mon
00a0: 61 68 61 6e 63 6a 0d 0a 23 20 6c 69 63 65 6e 73  ahancj..# licens
00b0: 65 3a 20 43 43 30 0d 0a 23 20 66 75 6e 63 74 69  e: CC0..# functi
00c0: 6f 6e 3a 20 47 65 74 2d 4e 6f 77 0d 0a 23 20 78  on: Get-Now..# x
00d0: 2d 70 6f 73 68 63 6f 64 65 2d 69 64 3a 20 33 39  -poshcode-id: 39
00e0: 32 33 0d 0a 23 20 78 2d 61 72 63 68 69 76 65 64  23..# x-archived
00f0: 3a 20 32 30 31 36 2d 30 33 2d 30 33 54 31 39 3a  : 2016-03-03T19:
0100: 32 37 3a 34 34 0d 0a 23 20 78 2d 70 75 62 6c 69  27:44..# x-publi
0110: 73 68 65 64 3a 20 32 30 31 33 2d 30 31 2d 33 30  shed: 2013-01-30
0120: 54 31 34 3a 31 32 3a 30 30 0d 0a 23 0d 0a 23 0d  T14:12:00..#..#.
0130: 0a 3c 23 0d 0a 2e 53 79 6e 6f 70 73 69 73 0d 0a  .<#...Synopsis..
0140: 20 20 20 20 43 6f 6e 6e 65 63 74 73 20 74 6f 20      Connects to 
0150: 6d 75 6c 74 69 70 6c 65 20 55 43 53 20 65 6e 76  multiple UCS env
0160: 69 72 6f 6e 6d 65 6e 74 73 20 6c 69 73 74 65 64  ironments listed
0170: 20 69 6e 20 61 20 74 65 78 74 20 66 69 6c 65 20   in a text file 
0180: 61 6e 64 20 67 65 6e 65 72 61 74 65 73 20 61 20  and generates a 
0190: 62 61 73 69 63 20 66 61 75 6c 74 20 72 65 70 6f  basic fault repo
01a0: 72 74 20 66 6f 72 20 65 61 63 68 20 6f 6e 65 2c  rt for each one,
01b0: 20 74 68 65 6e 20 73 65 6e 64 73 20 6f 6e 65 20   then sends one 
01c0: 65 6d 61 69 6c 20 77 69 74 68 20 74 68 65 20 72  email with the r
01d0: 65 73 75 6c 74 73 2e 20 20 49 6e 20 74 68 65 20  esults.  In the 
01e0: 72 65 70 6f 72 74 20 61 72 65 20 75 6e 61 63 6b  report are unack
01f0: 6e 6f 77 6c 65 64 67 65 64 20 66 61 75 6c 74 73  nowledged faults
0200: 2c 20 68 61 72 64 77 61 72 65 20 6c 6f 63 61 74  , hardware locat
0210: 6f 72 20 4c 45 44 73 20 74 68 61 74 20 61 72 65  or LEDs that are
0220: 20 6f 6e 2c 20 61 6e 64 20 69 66 20 79 6f 75 20   on, and if you 
0230: 61 72 65 20 73 68 6f 72 74 20 6f 6e 20 70 6f 72  are short on por
0240: 74 20 6c 69 63 65 6e 73 65 73 20 69 74 20 77 69  t licenses it wi
0250: 6c 6c 20 73 68 6f 77 20 74 68 61 74 2e 20 20 56  ll show that.  V
0260: 61 72 69 61 62 6c 65 73 20 61 6e 64 20 70 61 74  ariables and pat
0270: 68 73 20 77 69 6c 6c 20 68 61 76 65 20 74 6f 20  hs will have to 
0280: 62 65 20 63 68 61 6e 67 65 64 20 74 6f 20 6d 61  be changed to ma
0290: 74 63 68 20 79 6f 75 72 20 65 6e 76 69 72 6f 6e  tch your environ
02a0: 6d 65 6e 74 2e 0d 0a 2e 42 6c 6f 67 0d 0a 09 62  ment....Blog...b
02b0: 61 74 63 68 6c 69 66 65 2e 77 6f 72 64 70 72 65  atchlife.wordpre
02c0: 73 73 2e 63 6f 6d 0d 0a 23 3e 0d 0a 0d 0a 70 61  ss.com..#>....pa
02d0: 72 61 6d 28 24 43 72 65 64 65 6e 74 69 61 6c 46  ram($CredentialF
02e0: 69 6c 65 3d 24 6e 75 6c 6c 29 0d 0a 0d 0a 69 66  ile=$null)....if
02f0: 20 28 24 43 72 65 64 65 6e 74 69 61 6c 46 69 6c   ($CredentialFil
0300: 65 20 2d 65 71 20 24 6e 75 6c 6c 29 20 7b 20 57  e -eq $null) { W
0310: 72 69 74 65 2d 48 6f 73 74 20 22 4d 69 73 73 69  rite-Host "Missi
0320: 6e 67 20 74 68 65 20 70 61 74 68 20 74 6f 20 74  ng the path to t
0330: 68 65 20 63 72 65 64 65 6e 74 69 61 6c 20 66 69  he credential fi
0340: 6c 65 2e 22 20 2d 42 61 63 6b 67 72 6f 75 6e 64  le." -Background
0350: 43 6f 6c 6f 72 20 44 61 72 6b 59 65 6c 6c 6f 77  Color DarkYellow
0360: 20 2d 46 6f 72 65 67 72 6f 75 6e 64 43 6f 6c 6f   -ForegroundColo
0370: 72 20 44 61 72 6b 52 65 64 3b 20 62 72 65 61 6b  r DarkRed; break
0380: 20 7d 0d 0a 0d 0a 0d 0a 23 2d 2d 2d 2d 2d 2d 2d   }......#-------
0390: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
03a0: 2d 2d 2d 2d 2d 2d 0d 0a 23 20 50 72 65 70 0d 0a  ------..# Prep..
03b0: 23 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  #---------------
03c0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a  --------------..
03d0: 66 75 6e 63 74 69 6f 6e 20 47 65 74 2d 4e 6f 77  function Get-Now
03e0: 20 7b 20 28 67 65 74 2d 64 61 74 65 20 2d 75 66   { (get-date -uf
03f0: 6f 72 6d 61 74 20 25 59 25 6d 25 64 29 20 2b 20  ormat %Y%m%d) + 
0400: 22 5f 22 20 2b 20 28 67 65 74 2d 64 61 74 65 20  "_" + (get-date 
0410: 2d 75 66 6f 72 6d 61 74 20 25 48 25 4d 25 53 29  -uformat %H%M%S)
0420: 20 7d 0d 0a 69 66 20 28 28 47 65 74 2d 4d 6f 64   }..if ((Get-Mod
0430: 75 6c 65 20 2d 4e 61 6d 65 20 43 69 73 63 6f 55  ule -Name CiscoU
0440: 63 73 50 53 29 20 2d 65 71 20 24 6e 75 6c 6c 29  csPS) -eq $null)
0450: 20 7b 20 49 6d 70 6f 72 74 2d 4d 6f 64 75 6c 65   { Import-Module
0460: 20 2d 4e 61 6d 65 20 43 3a 5c 4f 70 73 5c 4d 6f   -Name C:\Ops\Mo
0470: 64 75 6c 65 73 5c 43 69 73 63 6f 55 43 53 50 6f  dules\CiscoUCSPo
0480: 77 65 72 54 6f 6f 6c 5c 43 69 73 63 6f 55 63 73  werTool\CiscoUcs
0490: 50 53 2e 70 73 64 31 20 7d 0d 0a 0d 0a 23 53 74  PS.psd1 }....#St
04a0: 61 74 69 63 20 70 61 72 61 6d 65 74 65 72 73 0d  atic parameters.
04b0: 0a 53 65 74 2d 56 61 72 69 61 62 6c 65 20 2d 4e  .Set-Variable -N
04c0: 61 6d 65 20 53 63 72 69 70 74 44 69 72 20 20 20  ame ScriptDir   
04d0: 2d 56 61 6c 75 65 20 22 43 3a 5c 53 63 72 69 70  -Value "C:\Scrip
04e0: 74 73 22 20 2d 53 63 6f 70 65 20 4c 6f 63 61 6c  ts" -Scope Local
04f0: 0d 0a 53 65 74 2d 56 61 72 69 61 62 6c 65 20 2d  ..Set-Variable -
0500: 4e 61 6d 65 20 52 65 70 6f 72 74 50 61 74 68 20  Name ReportPath 
0510: 20 2d 56 61 6c 75 65 20 22 43 3a 5c 53 63 72 69   -Value "C:\Scri
0520: 70 74 73 5c 52 65 70 6f 72 74 73 5c 55 43 53 5f  pts\Reports\UCS_
0530: 46 61 75 6c 74 5f 52 65 70 6f 72 74 73 22 20 2d  Fault_Reports" -
0540: 53 63 6f 70 65 20 4c 6f 63 61 6c 0d 0a 53 65 74  Scope Local..Set
0550: 2d 56 61 72 69 61 62 6c 65 20 2d 4e 61 6d 65 20  -Variable -Name 
0560: 52 65 70 6f 72 74 46 69 6c 65 20 20 2d 56 61 6c  ReportFile  -Val
0570: 75 65 20 22 24 28 24 52 65 70 6f 72 74 50 61 74  ue "$($ReportPat
0580: 68 29 5c 55 43 53 5f 46 61 75 6c 74 5f 52 65 70  h)\UCS_Fault_Rep
0590: 6f 72 74 5f 24 28 47 65 74 2d 4e 6f 77 29 2e 68  ort_$(Get-Now).h
05a0: 74 6d 6c 22 20 2d 53 63 6f 70 65 20 4c 6f 63 61  tml" -Scope Loca
05b0: 6c 0d 0a 57 72 69 74 65 2d 56 65 72 62 6f 73 65  l..Write-Verbose
05c0: 20 22 60 6e 53 74 61 74 69 63 20 70 61 72 61 6d   "`nStatic param
05d0: 65 74 65 72 73 60 6e 2d 2d 2d 2d 2d 2d 2d 2d 2d  eters`n---------
05e0: 2d 2d 2d 2d 2d 2d 2d 2d 60 6e 53 63 72 69 70 74  --------`nScript
05f0: 44 69 72 20 3d 20 24 28 24 53 63 72 69 70 74 44  Dir = $($ScriptD
0600: 69 72 29 60 6e 52 65 70 6f 72 74 46 69 6c 65 20  ir)`nReportFile 
0610: 3d 20 24 28 24 52 65 70 6f 72 74 46 69 6c 65 29  = $($ReportFile)
0620: 60 6e 22 0d 0a 24 6d 61 69 6c 54 6f 20 3d 20 22  `n"..$mailTo = "
0630: 61 6c 65 72 74 73 64 69 73 74 67 72 6f 75 70 40  alertsdistgroup@
0640: 79 6f 75 72 63 6f 6d 70 61 6e 79 2e 63 6f 6d 22  yourcompany.com"
0650: 0d 0a 24 6d 61 69 6c 46 72 6f 6d 20 3d 20 22 55  ..$mailFrom = "U
0660: 43 53 5f 46 61 75 6c 74 5f 52 65 70 6f 72 74 73  CS_Fault_Reports
0670: 40 79 6f 75 72 63 6f 6d 70 61 6e 79 2e 63 6f 6d  @yourcompany.com
0680: 22 0d 0a 24 6d 61 69 6c 53 4d 54 50 20 3d 20 22  "..$mailSMTP = "
0690: 73 6d 74 70 2e 79 6f 75 72 63 6f 6d 70 61 6e 79  smtp.yourcompany
06a0: 2e 63 6f 6d 22 0d 0a 0d 0a 49 66 20 28 20 21 28  .com"....If ( !(
06b0: 54 65 73 74 2d 50 61 74 68 20 24 52 65 70 6f 72  Test-Path $Repor
06c0: 74 50 61 74 68 29 20 29 20 7b 20 6d 6b 64 69 72  tPath) ) { mkdir
06d0: 20 24 52 65 70 6f 72 74 50 61 74 68 20 7d 0d 0a   $ReportPath }..
06e0: 2e 20 24 53 63 72 69 70 74 44 69 72 5c 48 61 6c  . $ScriptDir\Hal
06f0: 73 5f 50 53 43 72 65 64 65 6e 74 69 61 6c 73 2e  s_PSCredentials.
0700: 70 73 31 0d 0a 23 20 53 65 74 75 70 20 63 72 65  ps1..# Setup cre
0710: 64 65 6e 74 69 61 6c 73 20 61 73 20 64 65 73 63  dentials as desc
0720: 72 69 62 65 64 20 69 6e 20 68 74 74 70 3a 2f 2f  ribed in http://
0730: 62 61 74 63 68 6c 69 66 65 2e 77 6f 72 64 70 72  batchlife.wordpr
0740: 65 73 73 2e 63 6f 6d 2f 32 30 31 32 2f 31 31 2f  ess.com/2012/11/
0750: 31 34 2f 70 6f 77 65 72 73 68 65 6c 6c 2d 73 63  14/powershell-sc
0760: 72 69 70 74 2d 74 6f 2d 62 61 63 6b 75 70 2d 61  ript-to-backup-a
0770: 2d 63 69 73 63 6f 2d 75 63 73 2d 66 61 62 72 69  -cisco-ucs-fabri
0780: 63 2d 69 6e 74 65 72 63 6f 6e 6e 65 63 74 2d 75  c-interconnect-u
0790: 73 69 6e 67 2d 74 68 65 2d 63 69 73 63 6f 2d 70  sing-the-cisco-p
07a0: 6f 77 65 72 74 6f 6f 6c 2d 63 6d 64 6c 65 74 73  owertool-cmdlets
07b0: 2f 0d 0a 0d 0a 24 55 63 73 43 72 65 64 20 3d 20  /....$UcsCred = 
07c0: 49 6d 70 6f 72 74 2d 50 73 43 72 65 64 65 6e 74  Import-PsCredent
07d0: 69 61 6c 20 2d 50 61 74 68 20 24 43 72 65 64 65  ial -Path $Crede
07e0: 6e 74 69 61 6c 46 69 6c 65 0d 0a 0d 0a 0d 0a 23  ntialFile......#
07f0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0800: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a 23  -------------..#
0810: 20 53 74 61 72 74 20 64 6f 69 6e 67 20 74 68 65   Start doing the
0820: 20 72 65 61 6c 20 77 6f 72 6b 2e 0d 0a 23 2d 2d   real work...#--
0830: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0840: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a 0d 0a 44  -----------....D
0850: 69 73 63 6f 6e 6e 65 63 74 2d 55 63 73 20 32 3e  isconnect-Ucs 2>
0860: 24 6e 75 6c 6c 20 23 20 43 6f 6e 6e 65 63 74 2d  $null # Connect-
0870: 55 63 73 20 77 69 6c 6c 20 66 61 69 6c 20 69 66  Ucs will fail if
0880: 20 79 6f 75 27 72 65 20 61 6c 72 65 61 64 79 20   you're already 
0890: 63 6f 6e 6e 65 63 74 65 64 20 74 6f 20 61 20 55  connected to a U
08a0: 43 53 0d 0a 0d 0a 22 3c 70 72 65 3e 22 20 7c 20  CS...."<pre>" | 
08b0: 4f 75 74 2d 46 69 6c 65 20 2d 46 69 6c 65 50 61  Out-File -FilePa
08c0: 74 68 20 24 52 65 70 6f 72 74 46 69 6c 65 20 2d  th $ReportFile -
08d0: 57 69 64 74 68 20 34 30 30 0d 0a 47 65 74 2d 44  Width 400..Get-D
08e0: 61 74 65 20 7c 20 4f 75 74 2d 46 69 6c 65 20 2d  ate | Out-File -
08f0: 46 69 6c 65 50 61 74 68 20 24 52 65 70 6f 72 74  FilePath $Report
0900: 46 69 6c 65 20 2d 41 70 70 65 6e 64 20 2d 57 69  File -Append -Wi
0910: 64 74 68 20 34 30 30 0d 0a 0d 0a 47 65 74 2d 43  dth 400....Get-C
0920: 6f 6e 74 65 6e 74 20 43 3a 5c 53 63 72 69 70 74  ontent C:\Script
0930: 73 5c 52 65 70 6f 5c 53 74 61 74 69 63 49 6e 66  s\Repo\StaticInf
0940: 6f 5c 55 43 53 73 2e 74 78 74 20 7c 20 46 6f 72  o\UCSs.txt | For
0950: 45 61 63 68 2d 4f 62 6a 65 63 74 20 7b 20 0d 0a  Each-Object { ..
0960: 09 57 72 69 74 65 2d 4f 75 74 70 75 74 20 22 3d  .Write-Output "=
0970: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
0980: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
0990: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
09a0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
09b0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
09c0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
09d0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 22 0d 0a 09 43 6f 6e  ========="...Con
09e0: 6e 65 63 74 2d 55 63 73 20 2d 4e 61 6d 65 20 24  nect-Ucs -Name $
09f0: 5f 20 2d 43 72 65 64 65 6e 74 69 61 6c 20 24 55  _ -Credential $U
0a00: 63 73 43 72 65 64 20 7c 20 73 65 6c 65 63 74 20  csCred | select 
0a10: 6e 61 6d 65 2c 76 65 72 73 69 6f 6e 2c 75 73 65  name,version,use
0a20: 72 6e 61 6d 65 2c 76 69 72 74 75 61 6c 69 70 76  rname,virtualipv
0a30: 34 61 64 64 72 65 73 73 20 7c 20 66 74 20 2d 61  4address | ft -a
0a40: 0d 0a 09 69 66 20 28 24 44 65 66 61 75 6c 74 55  ...if ($DefaultU
0a50: 63 73 20 2d 65 71 20 24 6e 75 6c 6c 29 20 7b 0d  cs -eq $null) {.
0a60: 0a 09 09 24 6d 61 69 6c 42 6f 64 79 20 3d 20 40  ...$mailBody = @
0a70: 28 29 0d 0a 20 20 20 20 09 24 6d 61 69 6c 42 6f  ()..    .$mailBo
0a80: 64 79 20 2b 3d 20 22 24 28 47 65 74 2d 4e 6f 77  dy += "$(Get-Now
0a90: 29 20 2d 20 45 72 72 6f 72 20 63 6f 6e 6e 65 63  ) - Error connec
0aa0: 74 69 6e 67 20 74 6f 20 55 43 53 60 6e 60 6e 22  ting to UCS`n`n"
0ab0: 0d 0a 20 20 20 20 09 24 6d 61 69 6c 42 6f 64 79  ..    .$mailBody
0ac0: 20 2b 3d 20 24 5f 0d 0a 20 20 20 20 09 53 65 6e   += $_..    .Sen
0ad0: 64 2d 4d 61 69 6c 4d 65 73 73 61 67 65 20 20 2d  d-MailMessage  -
0ae0: 46 72 6f 6d 20 24 6d 61 69 6c 46 72 6f 6d 20 2d  From $mailFrom -
0af0: 54 6f 20 24 6d 61 69 6c 54 6f 20 2d 53 75 62 6a  To $mailTo -Subj
0b00: 65 63 74 20 22 42 61 63 6b 75 70 2d 6d 55 63 73  ect "Backup-mUcs
0b10: 20 45 72 72 6f 72 2d 2d 20 46 61 69 6c 65 64 20   Error-- Failed 
0b20: 63 6f 6e 6e 65 63 74 69 6e 67 20 74 6f 20 24 28  connecting to $(
0b30: 24 55 63 73 29 22 20 2d 42 6f 64 79 20 28 24 6d  $Ucs)" -Body ($m
0b40: 61 69 6c 42 6f 64 79 20 7c 20 4f 75 74 2d 53 74  ailBody | Out-St
0b50: 72 69 6e 67 29 20 2d 53 6d 74 70 53 65 72 76 65  ring) -SmtpServe
0b60: 72 20 24 6d 61 69 6c 53 4d 54 50 0d 0a 09 7d 0d  r $mailSMTP...}.
0b70: 0a 09 65 6c 73 65 20 7b 0d 0a 09 09 47 65 74 2d  ..else {....Get-
0b80: 55 63 73 46 61 75 6c 74 20 7c 20 57 68 65 72 65  UcsFault | Where
0b90: 2d 4f 62 6a 65 63 74 20 7b 20 28 24 5f 2e 53 65  -Object { ($_.Se
0ba0: 76 65 72 69 74 79 20 2d 6e 65 20 27 63 6c 65 61  verity -ne 'clea
0bb0: 72 65 64 27 29 20 2d 61 6e 64 20 28 24 5f 2e 41  red') -and ($_.A
0bc0: 63 6b 20 2d 6e 65 20 27 79 65 73 27 29 20 7d 20  ck -ne 'yes') } 
0bd0: 7c 20 73 6f 72 74 20 6c 61 73 74 74 72 61 6e 73  | sort lasttrans
0be0: 69 74 69 6f 6e 20 2d 44 65 73 63 65 6e 64 69 6e  ition -Descendin
0bf0: 67 20 7c 20 73 65 6c 65 63 74 20 6c 61 73 74 74  g | select lastt
0c00: 72 61 6e 73 69 74 69 6f 6e 2c 73 65 76 65 72 69  ransition,severi
0c10: 74 79 2c 73 74 61 74 75 73 2c 74 79 70 65 2c 64  ty,status,type,d
0c20: 6e 2c 64 65 73 63 72 20 7c 20 66 74 20 2d 61 0d  n,descr | ft -a.
0c30: 0a 09 09 47 65 74 2d 55 63 73 4c 6f 63 61 74 6f  ...Get-UcsLocato
0c40: 72 4c 65 64 20 7c 20 3f 20 7b 20 24 5f 2e 6f 70  rLed | ? { $_.op
0c50: 65 72 73 74 61 74 65 20 2d 65 71 20 27 6f 6e 27  erstate -eq 'on'
0c60: 20 7d 20 7c 20 73 6f 72 74 20 64 6e 20 7c 20 73   } | sort dn | s
0c70: 65 6c 65 63 74 20 64 6e 2c 61 64 6d 69 6e 73 74  elect dn,adminst
0c80: 61 74 65 2c 63 6f 6c 6f 72 2c 6f 70 65 72 73 74  ate,color,operst
0c90: 61 74 65 2c 69 64 20 7c 20 66 74 20 2d 61 0d 0a  ate,id | ft -a..
0ca0: 09 09 49 66 20 28 47 65 74 2d 55 63 73 46 61 75  ..If (Get-UcsFau
0cb0: 6c 74 20 7c 20 57 68 65 72 65 2d 4f 62 6a 65 63  lt | Where-Objec
0cc0: 74 20 7b 20 28 24 5f 2e 53 65 76 65 72 69 74 79  t { ($_.Severity
0cd0: 20 2d 6e 65 20 27 63 6c 65 61 72 65 64 27 29 20   -ne 'cleared') 
0ce0: 2d 61 6e 64 20 28 24 5f 2e 44 6e 20 2d 6d 61 74  -and ($_.Dn -mat
0cf0: 63 68 20 27 46 30 36 37 36 27 29 20 7d 20 29 20  ch 'F0676') } ) 
0d00: 7b 20 0d 0a 09 09 09 22 60 6e 2d 2d 2d 2d 2d 2d  { ....."`n------
0d10: 20 50 6f 72 74 20 4c 69 63 65 6e 73 65 73 20 4e   Port Licenses N
0d20: 65 65 64 65 64 20 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  eeded ----------
0d30: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0d40: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0d50: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0d60: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0d70: 2d 2d 22 0d 0a 09 09 09 47 65 74 2d 55 63 73 4c  --".....Get-UcsL
0d80: 69 63 65 6e 73 65 20 7c 20 53 65 6c 65 63 74 2d  icense | Select-
0d90: 4f 62 6a 65 63 74 20 55 63 73 2c 53 63 6f 70 65  Object Ucs,Scope
0da0: 2c 46 65 61 74 75 72 65 2c 53 6b 75 2c 41 62 73  ,Feature,Sku,Abs
0db0: 51 75 61 6e 74 2c 44 65 66 51 75 61 6e 74 2c 55  Quant,DefQuant,U
0dc0: 73 65 64 51 75 61 6e 74 2c 40 7b 6e 3d 22 52 65  sedQuant,@{n="Re
0dd0: 6d 51 75 61 6e 74 22 3b 65 3d 7b 24 5f 2e 41 62  mQuant";e={$_.Ab
0de0: 73 51 75 61 6e 74 2d 24 5f 2e 55 73 65 64 51 75  sQuant-$_.UsedQu
0df0: 61 6e 74 7d 7d 2c 53 74 61 74 75 73 2c 50 65 65  ant}},Status,Pee
0e00: 72 53 74 61 74 75 73 2c 4f 70 65 72 53 74 61 74  rStatus,OperStat
0e10: 65 2c 47 72 61 63 65 50 65 72 69 6f 64 55 73 65  e,GracePeriodUse
0e20: 64 20 7c 20 66 74 20 2d 61 0d 0a 09 09 09 47 65  d | ft -a.....Ge
0e30: 74 2d 55 63 73 4c 69 63 65 6e 73 65 53 65 72 76  t-UcsLicenseServ
0e40: 65 72 48 6f 73 74 49 64 20 7c 20 73 65 6c 65 63  erHostId | selec
0e50: 74 20 75 63 73 2c 72 6e 2c 68 6f 73 74 69 64 20  t ucs,rn,hostid 
0e60: 7c 20 66 74 20 2d 61 0d 0a 09 09 7d 0d 0a 09 09  | ft -a....}....
0e70: 44 69 73 63 6f 6e 6e 65 63 74 2d 55 63 73 20 0d  Disconnect-Ucs .
0e80: 0a 09 7d 0d 0a 7d 20 7c 20 4f 75 74 2d 46 69 6c  ..}..} | Out-Fil
0e90: 65 20 2d 46 69 6c 65 50 61 74 68 20 24 52 65 70  e -FilePath $Rep
0ea0: 6f 72 74 46 69 6c 65 20 2d 41 70 70 65 6e 64 20  ortFile -Append 
0eb0: 2d 57 69 64 74 68 20 34 30 30 0d 0a 0d 0a 22 3c  -Width 400...."<
0ec0: 2f 70 72 65 3e 22 20 7c 20 4f 75 74 2d 46 69 6c  /pre>" | Out-Fil
0ed0: 65 20 2d 46 69 6c 65 50 61 74 68 20 24 52 65 70  e -FilePath $Rep
0ee0: 6f 72 74 46 69 6c 65 20 2d 41 70 70 65 6e 64 20  ortFile -Append 
0ef0: 2d 57 69 64 74 68 20 34 30 30 0d 0a 0d 0a 24 62  -Width 400....$b
0f00: 6f 64 79 20 3d 20 47 65 74 2d 43 6f 6e 74 65 6e  ody = Get-Conten
0f10: 74 20 24 52 65 70 6f 72 74 46 69 6c 65 0d 0a 0d  t $ReportFile...
0f20: 0a 53 65 6e 64 2d 4d 61 69 6c 4d 65 73 73 61 67  .Send-MailMessag
0f30: 65 20 20 2d 46 72 6f 6d 20 24 6d 61 69 6c 46 72  e  -From $mailFr
0f40: 6f 6d 20 2d 54 6f 20 24 6d 61 69 6c 54 6f 20 2d  om -To $mailTo -
0f50: 53 75 62 6a 65 63 74 20 22 55 43 53 20 46 61 75  Subject "UCS Fau
0f60: 6c 74 20 52 65 70 6f 72 74 20 24 28 47 65 74 2d  lt Report $(Get-
0f70: 44 61 74 65 29 22 20 2d 42 6f 64 79 20 28 24 62  Date)" -Body ($b
0f80: 6f 64 79 20 7c 20 4f 75 74 2d 53 74 72 69 6e 67  ody | Out-String
0f90: 29 20 2d 42 6f 64 79 41 73 48 54 4d 4c 20 2d 53  ) -BodyAsHTML -S
0fa0: 6d 74 70 53 65 72 76 65 72 20 24 6d 61 69 6c 53  mtpServer $mailS
0fb0: 4d 54 50 0d 0a                                   MTP..