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
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
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
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
$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
$File = New-Item -ItemType File -Path c:\SpecialFolder\SpecialFile.txt -Force | |
$Bill = New-LocalUser "Bill Bennsson" -Password (ConvertTo-SecureString -String BillAdmin -AsPlainText -Force) | |
$Andy = New-LocalUser "Andy Pandien" -Password (ConvertTo-SecureString -String AndyUser -AsPlainText -Force) | |
$Access = [System.Security.AccessControl.FileSystemAccessRule]::new($Bill.SID,"Modify","Allow"),[System.Security.AccessControl.FileSystemAccessRule]::new($Andy.SID,"Read","Allow") | |
$NewACL=[System.Security.AccessControl.DirectorySecurity]::new() | |
$NewACL.SetSecurityDescriptorSddlForm('D:') | |
$NewACL.SetAccessRuleProtection($True, $True) | |
$Access | ForEach-Object {$NewACL.AddAccessRule($_)} | |
Set-Acl $File.FullName $NewACL |
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
class ComputerInfo { | |
[string]$ComputerName | |
[string]$BIOSManufacturer | |
[string]$BIOSVersion | |
[string]$Domain | |
[int]$Processors | |
[int]$Cores | |
[int]$TotalPhysicalMemoryGB | |
[string]$OSName | |
[string]$OSArchitecture |
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-UpTime { | |
[CmdletBinding()] | |
param ([parameter(ValueFromPipeline)][string]$ComputerName,[PSCredential]$Credential,$Authentication) | |
$Parameters = @{ | |
ScriptBlock = [scriptblock]::Create('if($env:OS -match "Windows"){$strBoot = $((systeminfo | find "System Boot Time") -replace "^.+:\s+|,")} else {$strBoot = (who -b) -replace "^\D+"}; Get-Date $strBoot') | |
} | |
if (!$ComputerName){$ComputerName = hostname} | |
if ($Credential){$Parameters.Add('Credential',$Credential);$Parameters.Add('ComputerName',$ComputerName)} | |
if ($Authentication){$Parameters.Add('Authentication',$Authentication)} | |
$BootDate = icm @Parameters |
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-CounterReport { | |
[CmdletBinding()] | |
param ($ComputerName=$env:COMPUTERNAME, | |
[system.io.fileinfo]$ExportCliXML, | |
[switch]$OutHTML, | |
[switch]$Quiet) | |
$OutputObject = [ordered]@{CollectionDate = $(Get-Date);ComputerName = $ComputerName} | |
$Parameters = @{ComputerName = $ComputerName} | |
Write-Verbose "Fetching Processor Time on $ComputerName" | |
$Parameters["Counter"] = "\\{0}\Processor(_Total)\% Processor Time" -f $ComputerName |
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-LegacyCommandObject { | |
[CmdletBinding()] | |
param ([ValidatePattern("^(netstat|arp)")] | |
[string]$CommandLine) | |
$Result = iex $CommandLine.split(';',2)[0] | |
$Headers = $Result -match '^\w+(`n`r)*' | |
foreach ($Line in $Result) { | |
if ($Line -match '^$'){$Collect = $False;$Properties=$Null;continue} | |
if ($Headers -contains $Line){$ObjHash=@{}; if ($Line -match ':'){$Parts = $Line.split(':',2).trim();$ObjHash.add($PArts[0],$Parts[1])};$Collect = $true;$CollectParametersHeader=$true;continue} |