This file contains 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
$ScheduledJobName = "CleanupTempFolder" | |
$ScriptBlock = [ScriptBlock]::Create(@' | |
[System.IO.FileInfo]$LogFile = "C:\Logs\CleanTempLog.log" | |
if (!$(Test-Path $LogFile.DirectoryName)){New-Item -ItemType Directory -Path $LogFile.DirectoryName} | |
function Get-TempFileObject { | |
param ($Timing) | |
$TempContent = Get-ChildItem $env:temp -Recurse -Force | |
[PSCustomObject]@{ | |
Filecount = ($TempContent | Where-Object {!$_.psiscontainer}).Count | |
Foldercount=($TempContent | Where-Object {$_.psiscontainer}).Count |
This file contains 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
if(([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]'Administrator')){(Get-WinEvent -ListLog * -ea 0 -Force).where{$_.RecordCount -gt 0}.foreach{if ($_.filesize/$_.MaximumSizeInBytes -gt 0.8){if ($_.LogMode -ne "Circular"){ $_.LogMode="Circular"}; $_.MaximumSizeInBytes=([math]::ceiling($_.MaximumSizeInBytes*1.1/64)*64);$_.SaveChanges(); 'EventLog {0} increased to {1} bytes. Logmode: {2}' -f $_.LogName,([math]::ceiling($_.MaximumSizeInBytes*1.1/64)*64),$_.LogMode | out-file $PSScriptRoot\EventlogFix.log -Append};$_} | select LogName ,RecordCount | sort RecordCount -Descending} else {Write-Warning "You must be an admin to run this script"} |
This file contains 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
Import-Module PartnerCenterModule | |
Import-Module PSExcel | |
$Destination = 'C:\Billing' | |
$BillingFilename = '{0}-{1}-{2}Billing.xlsx' | |
$clientSecret = 'Your super secret string' | |
$CSPAppID = 'Your App GUID' | |
$CSPDomain = 'Your CSP Domain' | |
$clientSecretSecure = $clientSecret | ConvertTo-SecureString -AsPlainText -Force | |
Add-PCAuthentication -cspAppID $CSPAppID -cspDomain $CSPDomain -cspClientSecret $clientSecretSecure | |
$Latest = Get-PCInvoice -all | Select-Object -First 1 |
This file contains 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
try { | |
$NuGet = Get-PackageProvider -ListAvailable -Name Nuget -ErrorAction Stop | |
} Catch { | |
# Logging to the console in Azure gives a warm and cosy feeling and provides documentation for your scripts | |
Write-Output "Installing NuGet" | |
Install-PackageProvider NuGet -Scope CurrentUser -Force | Out-Null | |
} | |
$PSLocalModulePath = "$($env:UserProfile)\Documents\WindowsPowershell\Modules" | |
# Test the existance of the path, and create it, if it doesn't exist |
This file contains 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
properties { | |
# This needs to be updated to fit your build | |
$psd1 = $ModuleRootFolder\MyModule.psd1 | |
} | |
Task IncrementVersion { | |
$CurrentVersion = Test-ModuleManifest $Script:psd1 | Select-Object -ExpandProperty Version | |
$Build = $ModuleManifestVersion.Build | |
$Minor = $ModuleManifestVersion.Minor | |
$Major = $ModuleManifestVersion.Major |
This file contains 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
{ | |
"kind": "template", | |
"properties": { | |
"template": { | |
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", | |
"contentVersion": "1.0.0.0", | |
"parameters": { | |
"storageAccountTypeFromBP": { | |
"type": "string", | |
"defaultValue": "Standard_LRS", |
This file contains 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
Out-Default -InputObject @{Source=$env:COMPUTERNAME;Target=$env:COMPUTERNAME} -PipelineVariable ST | foreach {compare-object (Get-WindowsFeature -ComputerName $ST['Source']).where{$_.installed} (Get-WindowsFeature -ComputerName $ST['Target']).where{$_.installed}} | ForEach-Object {if ($_.SideIndicator -eq '<='){Install-WindowsFeature -Name $_.InputObject.Name -ComputerName $ST['Target']} elseif ($_.SideIndicator -eq '=>') {Uninstall-WindowsFeature -Name $_.InputObject.Name -ComputerName $ST['Target']}} |
This file contains 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 Remove-AdminCount | |
{ | |
[CmdletBinding()] | |
param ($Samaccountname) | |
if (!$(Get-Module activedirectory)){import-module activedirectory} | |
try | |
{ | |
$User = Get-ADUser $Samaccountname -Properties Admincount | |
if ($User.Admincount -eq 1) | |
{ |
This file contains 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
param ($crypto = @" | |
P k T r 2 s z 2 * c F - | |
r a z 7 G u D 4 w 6 U # | |
g c t K 3 E @ B t 1 a Y | |
Q P i c % 7 0 5 Z v A e | |
W 6 j e P R f p m I ) H | |
y ^ L o o w C n b J d O | |
S i 9 M b e r # ) i e U | |
* f 2 Z 6 M S h 7 V u D | |
5 a ( h s v 8 e l 1 o W |
This file contains 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-FileInfo { | |
[CmdletBinding(DefaultParameterSetName='Local')] | |
param ( | |
# The Path parameter takes an array of strings to query. Pipe away if desired | |
[Parameter(ValueFromPipeline=$true)] | |
[Parameter(ParameterSetName = 'Local')] | |
[Parameter(ParameterSetName = 'Remote')] | |
[string[]] | |
$Path, | |
# The ComputerName parameter takes several computernames and executes the Get-FileInfo command against them |