Skip to content

Instantly share code, notes, and snippets.

View janegilring's full-sized avatar

Jan Egil Ring janegilring

View GitHub Profile
@janegilring
janegilring / New-DPMProtectionGroup.ps1
Created August 1, 2017 05:50
An example showing how to create a new protection group in System Center Data Protection Manager 2016. From the cmdlets help: "The New-DPMProtectionGroup cmdlet creates a protection group on a System Center 2016 - Data Protection Manager (DPM) server. This is the first step to create a protection group. This cmdlet returns a new protection group…
# Create the protection group object (the actual protection group will not be created until all necessary properties is specifed)
$PG = New-DPMProtectionGroup -Name '30 days - Application Servers'
# Select what DPM agent to protect
$server = Get-DPMProductionServer | Where-Object -Property MachineName -Value SRV01 -EQ
# Select data source from the specified DPM agent
$DataSource = Get-DPMDatasource -ProductionServer $server | Where-Object Name -eq 'E:\' | Get-DPMChildDatasource -Inquire |
Where-Object Name -eq 'IBM'| Get-DPMChildDatasource -Inquire | Where-Object Name -eq 'WebSphere' |
Get-DPMChildDatasource -Inquire | Where-Object Name -eq 'profiles'
TOPIC
about_Lability
SHORT DESCRIPTION
Lability is a local Hyper-V lab provisioning framework.
LONG DESCRIPTION
The Lability module enables simple provisioning of local Windows Hyper-V development and testing lab
@janegilring
janegilring / Lability-example.ps1
Created July 19, 2017 19:07
An example for setting up a basic lab environment using Lability
$ConfigData = @{
AllNodes = @(
@{
NodeName = 'DC1';
Lability_ProcessorCount = 2;
Lability_SwitchName = 'CORPNET';
Lability_Media = '2016_x64_Standard_Core_EN_Eval';
},
@{
NodeName = 'APP1';
@janegilring
janegilring / Lability.ps1
Created July 19, 2017 18:57
Example for getting started with Lability which should work on any Windows 10 computer capable of running Hyper-V
# The easiest way to install Lability is to leverage PowerShellGet
Find-Module -Name Lability |
Install-Module
# One advantage of doing so is that Update-Module makes it very convenient to update to the latest version at a later point in time
Update-Module -Name Lability
# Explore available commands
Get-Command -Module Lability
@janegilring
janegilring / DPMCX examples.ps1
Created June 4, 2017 05:24
Data Protection Manager Community Extensions PowerShell module examples
# Get active computer accounts from Active Directory who is running a server operating system
$Date = Get-Date
$InactiveComputerObjectThresholdInDays = '15'
$Servers = Get-ADComputer -LDAPFilter "(&(objectCategory=computer)(operatingSystem=Windows Server*)(!serviceprincipalname=*MSClusterVirtualServer*))" -Properties description,lastlogontimestamp,operatingsystem |
Where-Object {[datetime]::FromFileTime($_.lastlogontimestamp) -gt $Date.AddDays(-$InactiveComputerObjectThresholdInDays)} |
Select-Object -Property @{name='computername';e={$_.name}},operatingsystem |
Sort-Object -Property computername
# Retrieve all computers who has DPM installed
$DPMComputers = $Servers | Test-DPMCXComputer | Where-Object IsInstalled
@janegilring
janegilring / Remove-SMB1.ps1
Last active May 16, 2017 13:42
Examples on how SMB1 can be removed
# Suggestion 1: Define in PowerShell DSC configurations for target systems that SMB 1 should be absent
configuration HyperV {
Import-DscResource -ModuleName PSDesiredStateConfiguration
node localhost {
WindowsFeature SMB1 {
Ensure = 'Absent'
@janegilring
janegilring / Get-HotfixStatus.example.ps1
Created May 15, 2017 13:12
Example usage of the Get-HotFixStatus command
# Download and dot source the function (you could also put it into a module)
Invoke-WebRequest -Uri 'https://raw.githubusercontent.com/janegilring/PSCommunity/master/Inventory/Get-HotfixStatus.ps1' -OutFile "$env:temp\Get-HotfixStatus.ps1"
. "$env:temp\Get-HotfixStatus.ps1"
# Check out the command`s help examples
Get-Help Get-HotfixStatus -Examples
# Try them out
Get-HotfixStatus -Id KB4012214
@janegilring
janegilring / Schedule Tesla auto conditioning based on outside temperature.ps1
Last active February 19, 2017 20:29
Schedule Tesla auto conditioning based on outside temperature
Import-Module -Name Tesla
Connect-Tesla
$OutsideTemp = (Get-Tesla -Command climate_state).outside_temp
Write-Output "Outside temp is: $OutsideTemp"
if($OutsideTemp -lt 1) {
@janegilring
janegilring / Schedule Tesla auto conditioning - basic example.ps1
Created February 19, 2017 11:32
Schedule Tesla auto conditioning - basic example
Import-Module -Name Tesla
Connect-Tesla
Write-Output "$(Get-Date): Starting heating and sleeping for 10 minutes"
Set-Tesla -Command auto_conditioning_start
Start-Sleep 600
Write-Output "$(Get-Date): Stopping heating"
@janegilring
janegilring / Send-Office365MailMessage.ps1
Created January 20, 2017 07:55
Script for sending an e-mail via Office 365 (requires a valid Office 365 user with an Exchange mailbox). Useful for different scenarios, such as sending e-mail from an Azure Automation runbook.
$MailParameters = @{
From = 'Office 365 User <office365-user@domain.com>'
To = 'external-user@outlook.com'
Subject = 'Test from PowerShell'
Body = "Hello World"
SmtpServer = 'smtp.office365.com'
Port = '587'
Credential = Get-Credential -UserName office365-user@domain.com -Message 'Specify Office 365 user credential'
UseSsl = $true
}