Beiträge mit #PowerShellTips

#PowerShellTips

Öffentliche Beiträge auf X, die #PowerShellTips verwenden.

Verwandte Hashtags

  1. Sean Metcalf✓@PyroTek3
    @PyroTek3
    Have an array with properties and want to put all those properties into a new array, try this: $ADUserArray | select DistinguishedName -ExpandProperty DistinguishedName ExpandProperty in this instance removes the property "header": DistinguishedName ----------- #PowerShellTips
    219
  2. Sean Metcalf✓@PyroTek3
    I dabble in PowerShell & decided to share some tips that work for me. Want to provide an object property value in output? You can put it inside this: "$()" Write-Output "The user ($ADUser.ServicePrincipalName) has the SPN: ($ADUser.ServicePrincipalName)" #PowerShellTips
    745165
  3. Sean Metcalf✓@PyroTek3
    @PyroTek3
    I use help functionality in PowerShell cmdlets extensively Get-Help Get-ADUser -Examples Help Get-ADUser -Full I have found Googling the cmdlet name provides extensive information in an Microsoft reference doc. #PowerShellTips
    207
  4. Sean Metcalf✓@PyroTek3
    @PyroTek3
    Finding the right cmdlet to do something can be tough sometimes. get-command can help. Wildcard search for cmdlets with "GPO" in the name Get-Command "*GPO*" We can also look specifically in a PS module for cmdlets Get-Command -module GroupPolicy #PowerShellTips
    109
  5. Sean Metcalf✓@PyroTek3
    @PyroTek3
    If you have a block of code that you know may error out in some circumstances, you can hide it. Test-Connection TRDDC01 -ErrorAction SilentlyContinue Try & CATCH can help & provide helpful info Try { Do-Something } Catch { Write-Warning "An error occurred" } #PowerShellTips
    1012
  6. Sean Metcalf✓@PyroTek3
    @PyroTek3
    PowerShell works with math pretty easily and will even round numbers for you. [math]::Round(142.459347634,2) Rounds this number to the nearest 2nd decimal place (2 in parens) So, 142.46 [math]::Round( (($DateTime - $UserAccount.PasswordLastSet).Days / 365),2) #PowerShellTips
    103
  7. Mehr Beiträge anzeigen