This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $csvObjects = foreach($int in (0..10000)) | |
| { | |
| $date = get-date | |
| [pscustomobject]@{ | |
| id = (10000+$int) | |
| Msg = "this belongs to id $int" | |
| Date = $date.AddDays(2000-$int) | |
| Random = get-random | |
| ticks = $date.Ticks | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $GetEventLog = @{ | |
| After = Get-Date -Date "22.08.2016" | |
| LogName = "System" | |
| EntryType = "Information" | |
| InstanceId = 6006 | |
| } | |
| $GetEventLog.Add("Before",$GetEventLog.After.Adddays(5)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Get-SingleWeekDate | |
| { | |
| <# | |
| .Synopsis | |
| Get all dates for a specific day of the week on year forward. Please give me a better function name!! | |
| .DESCRIPTION | |
| Long description which is very short | |
| .EXAMPLE | |
| Get-SingleWeekDate -DayOfWeek Monday |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [cmdletbinding()] | |
| Param( | |
| [string]$ServiceName = "Bonjour Service" | |
| ) | |
| $f = $MyInvocation.InvocationName | Split-Path -Leaf | |
| Write-Verbose -Message "$f - START" | |
| $cimService = Get-CimInstance -Query "Select * from win32_Service where Name='$ServiceName'" -ErrorAction SilentlyContinue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Get-NumberRange | |
| { | |
| [cmdletbinding()] | |
| Param() | |
| DynamicParam { | |
| $Dictionary = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary | |
| $NewDynParam = @{ | |
| Name = "Firstnumber" | |
| Alias = "int" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Get-ChessScores | |
| { | |
| [cmdletbinding()] | |
| Param( | |
| [Parameter(ValueFromPipeline)] | |
| [string]$RootPath | |
| ) | |
| Begin { | |
| $SharpCode = @' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $OutputFile = "c:\temp\ConsistencyverboseStream.txt" | |
| $invokeCim = @{ | |
| Namespace = "root/Microsoft/Windows/DesiredStateConfiguration" | |
| Class = "MSFT_DSCLocalConfigurationManager" | |
| Method = "PerformRequiredConfigurationChecks" | |
| Arguments = @{Flags = [System.UInt32]1} | |
| } | |
| Invoke-CimMethod @invokeCim -Verbose 4>&1 | foreach {Out-File -Encoding utf8 -Append -FilePath $OutputFile -Inputobject $_} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $invokeCim = @{ | |
| Namespace = "root/Microsoft/Windows/DesiredStateConfiguration" | |
| Class = "MSFT_DSCLocalConfigurationManager" | |
| Method = "PerformRequiredConfigurationChecks" | |
| Arguments = @{Flags = [System.UInt32]1} | |
| } | |
| Invoke-CimMethod @invokeCim |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $users = Get-ADGroupMember G_Email_Archive_2013 | Select-Object -ExpandProperty name | |
| foreach ($user in $users) | |
| { | |
| # Extract Mailbox GUID and pipe to variable $GUID | |
| $GUID = Get-Mailbox $user | select ExchangeGUID | |
| $customAttrib3 = Get-Mailbox -Identity $user -CustomAttribute3 -ErrorAction SilentlyContinue | |
| if($customAttrib3) | |
| { | |
| #dersom CustomAttrib3 har verdi, så kan vi gjøre noe her | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Get-ReverseIP | |
| { | |
| [cmdletbinding()] | |
| [OutputType([String[]])] | |
| Param( | |
| [Parameter( | |
| ValueFromPipeline=$true, | |
| ValueFromPipelineByPropertyName=$true, | |
| ValueFromRemainingArguments=$false, | |
| Position=0)] |