Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Add-Type -AssemblyName office
- $Application = New-Object -ComObject PowerPoint.Application #start a new ComObject to launch powerpoint
- $Application.Visible = [Microsoft.Office.Core.MsoTriState]::msoTrue #make the powerpoint app visible
- $slideType = "microsoft.office.interop.powerpoint.ppSlideLayout" -as [type]
- $datadir = "c:\Script\Data" #set the Directory where all the data resides
- $templatePresentation = "C:\Script\Network-Monitor5.pptx" #assign our powerpoint presentation
- $presentation = $application.Presentations.open($templatePresentation) #this opens it
- $mydocument = $presentation.Slides.item(1) #this makes slide 1 the active one
- $mydocument.Shapes.Item("status").width = 120
- [int]$hour = Get-Date -format HH
- ############################################ Instantiate (initialize) the hash tables ##################################################################################
- $PrinterIP = ((Get-Content $datadir\Printers-IP-new.csv) -replace ",","=") -join "`n"|ConvertFrom-StringData
- $SwitchIP = ((Get-Content $datadir\Switches-IP.csv) -replace ",","=") -join "`n"|ConvertFrom-StringData
- $NetworkIP = ((Get-Content $datadir\Network-IP.csv) -replace ",","=") -join "`n"|ConvertFrom-StringData
- $ServerIP = ((Get-Content $datadir\Server-IP.csv) -replace ",","=") -join "`n"|ConvertFrom-StringData
- ############################################ End Instantiate (initialize) the hash tables ##############################################################################
- ############################################ CheckStatus Function Start ##################################################################
- #We write the function first because if you call the function before powershell sees it, it will not recognize the function and give you an error
- Function CheckStatus ($deviceip) {
- $tc = New-Object System.Net.Networkinformation.ping #connect to Microsoft network to ping
- $mydocument.Shapes.Item("status").Fill.Transparency = 0.15 #set the "status" transparencyy
- ForEach ($ip in $deviceip.GetEnumerator()) { #loop through each network device's IP
- $Status = $tc.Send($ip.Value).Status #send a ping and get the status. Store it in $status variable.
- Switch ($status) {
- "Success" {
- $mydocument.Shapes.Item($ip.Name).Fill.forecolor.RGB = "255,0,100" #change it to green color.
- $mydocument.Shapes.Item($ip.Name).Fill.Transparency = 1.0 #Make it invisible briefly for effect
- $mydocument.Shapes.Item($ip.Name).Fill.Transparency = 0.15 #Set transparency back
- }
- "TimedOut" {
- $mydocument.Shapes.Item($ip.Name).Fill.forecolor.RGB = "255,255,255" #change it to red to show we can't communicate
- $mydocument.Shapes.Item($ip.Name).Fill.Transparency = 1
- $mydocument.Shapes.Item($ip.Name).Fill.Transparency = 0.15
- }
- "DestinationHostUnreachable" {
- $mydocument.Shapes.Item($ip.Name).Fill.forecolor.RGB = "118,240,255" #change it to yellow
- $mydocument.Shapes.Item($ip.Name).Fill.Transparency = 1
- $mydocument.Shapes.Item($ip.Name).Fill.Transparency = 0.15
- }
- }
- }
- }
- ##################################################### Check Status Function End ########################################################################
- While ($env:UserName -ne "Satan"){ # keep running until we exit the script. It's looking for Ctuhlu as a username it will never happen.
- if($hour -lt 8 -or $hour -gt 16){}#do nothing
- Else {
- CheckStatus $PrinterIP #calls the check status function and passes info from our hashes declared above.
- CheckStatus $SwitchIP
- CheckStatus $NetworkIP
- CheckStatus $ServerIP
- [System.Windows.Forms.SendKeys]::SendWait("^") #don't allow the screen saver from GPO to kick in
- ######################################### Start Timer Countdown ###########################################################################################################
- for ($a=120; $a -ge 0; $a--) { #this is a timer. Set the $a= to however long you want the timer. You will have to manually adjust the status bar length in the ppx
- $mydocument.Shapes.Item("status").width = $a #this is the update status bar. It decreases the size of the shape.
- $mydocument.Shapes.Item("timer").Textframe.TextRange.text = "$a SECONDS"
- Start-Sleep 1
- }
- ####################################### End Timer Countdown ##############################################################################################################
- $mydocument.Shapes.Item("status").width = 120 #set the green status bar back to default length
- $mydocument.Shapes.Item("timer").TextFrame.TextRange.text = "120 SECONDS" #reset the timer display
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment