TEXT

Wednesday, September 21, 2022

Simple Function Do Something

 



 Use template below to create simple PS function 

 

# Simple Function Do Something

# Change $ReportName

 function Function-Do-Something{   

 [CmdletBinding()]

   param(

        [Parameter(Position=0,mandatory=$true)]

        [string] $ReportName)

  <CODE GOES HERE>

  }

 


Casey DeDeal

https://simplepowershell.blogspot.com
https://cloudsec365.blogspot.com
https://msazure365.blogspot.com
https://twitter.com/Message_Talk

Simple try and catch statement

 Here is simple example of try and catch statement.

 

# TRY CATCH

Try{

<Code Goes HERE>

}Catch{

$errormessage = $($PSItem.ToString())

  Write-Warning 'Error has occurred'

  Write-host 'Problem FOUND:' $errormessage -ForegroundColor Red -BackgroundColor White

}

 




Simple Function Do Something

   Use template below to create simple PS function    # Simple Function Do Something # Change $ReportName   function Fu...