Skip to content

Instantly share code, notes, and snippets.

@desek
desek / Get-OMSDKLogons.ps1
Last active August 29, 2015 14:06
OMSDK Logons from Event Log
$Events = Get-EventLog -LogName 'Operations Manager' -EntryType Information | Where-Object {$_.EventID -eq 26328}
$Logons = @()
Foreach ($Event in $Events)
{
If ($Event.ReplacementStrings[0] -notin @($Logons.UserName))
{
$Props = [ordered]@{
UserName = $Event.ReplacementStrings[0]
LastLogon = $Event.TimeGenerated
@desek
desek / DisableSMDWCubeProcessing.ps1
Last active August 29, 2015 14:06
Disable SCSM Cube processing and disable SSAS
# Script to remotely stoping and disabling all SCSM Cube Procesing jobs and SSAS instance
$SMDWServer = ""
$SSASServer = ""
$SSASInstanceName = "MSSQLSERVER"
Invoke-Command -ScriptBlock {
$smdir = (Get-ItemProperty "HKLM:\Software\Microsoft\System Center\2010\Service Manager\Setup").InstallDirectory
Import-Module "$smdir\Microsoft.EnterpriseManagement.Warehouse.Cmdlets.psd1"
$DWJobs = Get-SCDWJob | Where-Object {$_.Name -like "Process.*"}
Foreach ($DWJob in $SCDWJobs)
# Modified version of http://poshcode.org/5474 by @sorlov
function DoSomething {}
function Check-WindowsPreview
{
PARAM(
[int]$Sleep=10,
[switch]$WaitForIt
)
function Get-MSFT2014TechnicalPreview
{
[CmdletBinding()]
Param(
[ValidateScript({Test-Path $_})]
[string]$Path=(Get-Location),
[Switch]$WithProgress
)
BEGIN
{
@desek
desek / PSSessionSecurityConfiguration.ps1
Last active August 29, 2015 14:07
Remote Powershell security permissions
Set-PSSessionConfiguration -ShowSecurityDescriptorUI -Name Microsoft.PowerShell -Force
@desek
desek / GAASoutput.txt
Last active August 29, 2015 14:10
Generate Azure Automation Schedule(s) Output
PS C:\> GenerateAzureAutomationSchedules -AutomationAccount $AzureAutomationAccount -Verbose
VERBOSE: Found 35 Azure Automation Schedule(s) with same Hour Interval.
VERBOSE: Creted Azure Automation Schedule for "Every 1 Hour(s) at minute 0".
VERBOSE: Azure Automation Schedule for "Every 1 Hour(s) at minute 2" already exists.
VERBOSE: Azure Automation Schedule for "Every 1 Hour(s) at minute 4" already exists.
VERBOSE: Azure Automation Schedule for "Every 1 Hour(s) at minute 5" already exists.
VERBOSE: Azure Automation Schedule for "Every 1 Hour(s) at minute 6" already exists.
VERBOSE: Azure Automation Schedule for "Every 1 Hour(s) at minute 8" already exists.
VERBOSE: Azure Automation Schedule for "Every 1 Hour(s) at minute 10" already exists.
VERBOSE: Azure Automation Schedule for "Every 1 Hour(s) at minute 12" already exists.
@desek
desek / assignSchedulesToRunbook.ps1
Created November 27, 2014 10:19
Assign Schedule(s) to Runbook
# Set Azure Automation Account Name
$PSDefaultParameterValues += @{"*-AzureAutomation*:AutomationAccountName"=$AzureAutomationAccount.AutomationAccountName}
# Select one Runbook
$Runbook = Get-AzureAutomationRunbook | Out-GridView -PassThru
# Select one/multiple Schedule(s)
$Schedules = Get-AzureAutomationSchedule | Out-GridView -PassThru
# Assign Schedules to Runbook
@desek
desek / xmlconflooping.ps1
Last active August 29, 2015 14:10
XmlConf Looping
$XmlData = @'
<HostGroups>
<HostGroup Name="All Hosts">
<HostGroup Name="Oslo">
<LogicalNetworkDefinitions>
<LogicalNetworkDefinition name="LM Oslo">
<LogicalNetwork>Live Migration</LogicalNetwork>
<Subnet>192.168.5.0/24</Subnet>
<VlanID>5</VlanID>
</LogicalNetwork>
@desek
desek / aaassembliesandmodules.txt
Last active August 29, 2015 14:10
Azure Automation Assmeblies and Available Modules 2014-12-02
Scriptblock {
[appdomain]::CurrentDomain.GetAssemblies() | Format-Table ImageRuntimeVersion, FullName
Get-Module -ListAvailable | Format-Table Name, Version
}
ImageRuntimeVersion FullName
------------------- --------
v4.0.30319 mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyTok...
v4.0.30319 Orchestrator.Sandbox, Version=7.2.0.0, Culture=neutral, ...
v4.0.30319 Orchestrator.Shared, Version=7.2.0.0, Culture=neutral, P...
@desek
desek / Update-AzurePowershell.ps1
Last active August 29, 2015 14:21
Update Azure Powershell module with Powershell
# Get latest azure-powershell
$AzureModule = Get-Module -Name Azure* -ListAvailable
$LatestRelease = Invoke-RestMethod -Uri https://api.github.com/repos/Azure/azure-powershell/releases/latest -Method GET
If (-not($AzureModule) -or $AzureModule.Version.ToString() -ne $LatestRelease.name)
{
$Asset = $LatestRelease.assets | Where-Object {$_.name -like "*.msi"}
$OutFile = "{0}\{1}" -f $env:TEMP, $Asset.name
Invoke-WebRequest -Uri $Asset.browser_download_url -OutFile $Outfile -Method Get
Start-Process -FilePath msiexec.exe -ArgumentList @("/i $OutFile /qb") -Wait -PassThru
}