Skip to content

Instantly share code, notes, and snippets.

$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
}
$GetEventLog = @{
After = Get-Date -Date "22.08.2016"
LogName = "System"
EntryType = "Information"
InstanceId = 6006
}
$GetEventLog.Add("Before",$GetEventLog.After.Adddays(5))
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
[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
function Get-NumberRange
{
[cmdletbinding()]
Param()
DynamicParam {
$Dictionary = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary
$NewDynParam = @{
Name = "Firstnumber"
Alias = "int"
function Get-ChessScores
{
[cmdletbinding()]
Param(
[Parameter(ValueFromPipeline)]
[string]$RootPath
)
Begin {
$SharpCode = @'
$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 $_}
$invokeCim = @{
Namespace = "root/Microsoft/Windows/DesiredStateConfiguration"
Class = "MSFT_DSCLocalConfigurationManager"
Method = "PerformRequiredConfigurationChecks"
Arguments = @{Flags = [System.UInt32]1}
}
Invoke-CimMethod @invokeCim
$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
}
function Get-ReverseIP
{
[cmdletbinding()]
[OutputType([String[]])]
Param(
[Parameter(
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true,
ValueFromRemainingArguments=$false,
Position=0)]