Saturday, 10 April 2021

Splatting in PowerShell


#Example 1
##########

    $Params = @{
        "Path"        = "TestFile.txt"
        "Destination" = "CopiedFile.txt"
        "WhatIf"      = $True
        "Force"       = $True
      }
  
      Copy-Item @Params


#Example 2
##########

  $MailMessage = @{
    To = “me@mycompany.com
    From = “me@mycompany.com
    Subject = “Hi”
    Body = “Hello”
    Smtpserver = “smtphost”
    ErrorAction = “SilentlyContinue”
}

Send-MailMessage @MailMessage 


No comments:

Post a Comment