This file contains hidden or 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
| # 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' |
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| $ConfigData = @{ | |
| AllNodes = @( | |
| @{ | |
| NodeName = 'DC1'; | |
| Lability_ProcessorCount = 2; | |
| Lability_SwitchName = 'CORPNET'; | |
| Lability_Media = '2016_x64_Standard_Core_EN_Eval'; | |
| }, | |
| @{ | |
| NodeName = 'APP1'; |
This file contains hidden or 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
| # 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 |
This file contains hidden or 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
| # 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 |
This file contains hidden or 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
| # 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' |
This file contains hidden or 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
| # 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 |
This file contains hidden or 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 -Name Tesla | |
| Connect-Tesla | |
| $OutsideTemp = (Get-Tesla -Command climate_state).outside_temp | |
| Write-Output "Outside temp is: $OutsideTemp" | |
| if($OutsideTemp -lt 1) { |
This file contains hidden or 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 -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" |
This file contains hidden or 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
| $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 | |
| } |