Filip Kasaj

I can act how I want, but I can't want what I want.

User Tools

Site Tools


technet:powershell:powershelltips

PowerShell tips

  1. Get-Alias gp*
  2.  
  3. "hello, world".gettype()
  4.  
  5. [datetime]$a="4/20/2020"
  6.  
  7. $a|get-member
  8.  
  9. Get-Help "Get-Service" -Examples
  10.  
  11. $b = @()
  12. $a = "" | select name,count
  13. $b += $a
  14. $b | Add-Member -MemberType NoteProperty -Name Attribute1 -Value "" -force
  15.  
  16. $ErrorActionPreference = 'SilentlyContinue'
  17.  
  18. $dataCollection = [PSCustomObject]@{
  19. TXT = Resolve-DnsName $domain -Type TXT -Server 8.8.8.8
  20. }
  21.  
  22. $Report = [System.Collections.Generic.List[Object]]::new()
  23. $ReportLine = [PSCustomObject] @{
  24. TimeStamp = Get-Date
  25. User = "abc"
  26. Action = "def"
  27. Service = Get-Service }
  28. $Report.Add($ReportLine)
  29.  
  30. $a="one
  31. two
  32. three".split("`n")
  33.  
  34. Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn
  35.  
  36. (Get-Mailbox -anr filip|Get-MailboxStatistics).TotalItemSize.Value.toBytes()
  37.  
  38. [Microsoft.Exchange.Data.ByteQuantifiedSize]::parse("34.01 MB (35,666,338 bytes)")
  39.  
  40. ("34.01 MB (35,666,338 bytes)"|%{`
  41. ($_.Substring($_.indexof("(")+1,$_.indexof("b")-$_.indexof("(")-2)) -replace(",","")`
  42. })/1MB
  43.  
  44. GCM exsetup |%{$_.Fileversioninfo}
This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
technet/powershell/powershelltips.txt · Last modified: 2023/08/03 08:59 by fk