Skip to content
  • Home
  • About Me
  • Contact
Dowst.Dev
Dowst.Dev
PowerShell Weekly
Dowst.Dev
Dowst.Dev
PowerShell Weekly
  • Home
  • About Me
  • Contact
Conditional StatementsGeneral

Switch Statement

switch ($value) { 1 {"It is one."} 2 {"It is two."} 3 {"It is three."} 4 {"It is four."} }
Matthew DowstMar 29, 2019Mar 29, 2019
Read More
Conditional StatementsGeneral

If/ElseIf/Else Statement

# If $value equals 1 write True 1, else if it equals 2 write True 2, else write False if($value -eq 1){ Write-Host "True 1" } elseif($value -eq 2){ Write-Host "True 2" } else { Write-Host "False" }
Matthew DowstMar 29, 2019
Read More
Conditional StatementsGeneral

If/Else Statement

# If $value equals 1 write True, else write False if($value -eq 1){ Write-Host "True" } else { Write-Host "False" }
Matthew DowstMar 29, 2019
Read More
RemotingSecurity

Run Multiple Commands on Remote Machine

# Create a persistent connection to remote machine $Session = New-PSSession -ComputerName $Computer -Credential $Credential # Runs on remote machine Invoke-Command -Session $Session -ScriptBlock {Stop-Service -Name Bits} # Run on local machine Get-Service # Runs on remote machine again Invoke-Command -Session $Session -ScriptBlock {Start-Service -Name Bits}
Matthew DowstMar 29, 2019
Read More
RemotingSecurity

Run Command on Remote Machine with Credentials

$Credential = Get-Credential Invoke-Command -ComputerName $Computer -ScriptBlock {Stop-Service -Name Bits} -Credential $Credential
Matthew DowstMar 29, 2019
Read More
RemotingSecurity

Run Command on Remote Machine

$Credential = Get-Credential Invoke-Command -ComputerName $Computer -ScriptBlock {Stop-Service -Name Bits}
Matthew DowstMar 29, 2019
Read More
CredentialsSecurity

Prompt for Credentials

$Credential = Get-Credential
Matthew DowstMar 29, 2019
Read More
CredentialsSecurity

Create PS Credential from Strings

$Username = 'Username' $Password = 'Password' $SecureString = ConvertTo-SecureString $Password -AsPlainText -Force $Credential = New-Object System.Management.Automation.PSCredential $Username, $SecureString
Matthew DowstMar 29, 2019
Read More
DateTimeGeneral

DateTime to DateTime

$date.DateTime
Matthew DowstMar 28, 2019
Read More
RegexSearch StringStrings

Find characters between double quotes “

Matthew DowstMar 28, 2019Mar 29, 2019
Read More
1213141516


My name is Matthew Dowst and I am a father, author, blogger, Microsoft MVP in PowerShell and Azure Hybrid & Migration. And I am an enthusiast of all things PowerShell and DevOps.


Practical Automation with PowerShell
Now available on Amazon and all major book retailers

Categories

  • Active Directory
    • Groups
    • User
  • Automation
  • Azure
    • Intune
  • Collaboration
  • General
    • Array
    • Conditional Statements
    • DateTime
    • Forms/Prompts
    • Fun
    • Math
    • Tools
  • Platforms
    • SharePoint
  • PoshBytes
  • Security
    • Credentials
    • Remoting
  • Storage
    • Files
    • Folders
    • Shares
  • Strings
    • Combine Strings
    • Convert to String
    • Create String
    • Numbers
    • Regex
    • Replace String
    • Search String
    • Split String
    • String Casing
  • Systems
    • Networking
    • Performance
    • Registry
  • Uncategorized

Tags

array azure AzureAutomation conditions credential Credentials date-formats datetime dns else epoch Files Folders form friday-fun guid hardware if int ip-address join logic logs math password performance Permissions port prompt regex registry remote replace rounding search security Shares split string substring time-zones unix User webrequest wmi

Follow Me

  • About Me
  • Contact Me
  • PowerShell Weekly Archive
Copyright © 2026 - Yuki Westa Blog Theme By WP Moose