Skip to content

Instantly share code, notes, and snippets.

View cyberautomate's full-sized avatar

cyberautomate

View GitHub Profile
[DSCLocalConfigurationManager()]
configuration LCMConfigNames
{
param
(
[Parameter(Mandatory= $true)]
[string[]]$ComputerName,
[Parameter(Mandatory= $true)]
[string]$regKey,
configuration DisableFirewall {
param ()
Import-DscResource –ModuleName 'NetworkingDsc'
Node localhost
{
FirewallProfile DisableFirewall
{
Name = 'Domain'
Enabled = 'True'
Configuration SecurePullServerSQLDBgMSA {
Param (
[ValidateNotNullOrEmpty()]
[ string ] $NodeName = 'localhost',
[ValidateNotNullOrEmpty()]
[ string ] $Thumbprint = " $( Throw "Provide a valid certificate thumbprint to continue" ) ",
[ValidateNotNullOrEmpty()]
[ string ] $Guid = " $( Throw "Provide a valid GUID to continue" ) "
# You must have Chocolately installed first
# Usage example
# Install-MySoftware -Computers dc1,dc2,svr12,svr16 -Packages 'powershell.portable','microsoft-edge','microsoft-windows-terminal'
Function Install-MySoftware {
[CmdletBinding()]
Param(
[Parameter()]
[string[]]$Computers,
Function Get-Inventory {
<#
.SYNOPSIS
Gets a variety of computer information remotely and exports it to
a CSV file.
.PARAMETER Computers
Specifies the Computer names of devices to query
.INPUTS
System.String Get-Inventory can accept a string value to
determine the Computers parameter.
Function Format-MerchReports {
<#
.SYNOPSIS
Reformats and combines Merch by Amazon sales reports
.DESCRIPTION
1. Deletes the first 13 rows of each CSV in $csvPath
2. Combines the data from all the files
3. Adds column headers defined in $finalHeader
4. Outputs the file to $csvPath as formatted-Merchreports.csv
Function Get-LocalAdmins {
<#
.SYNOPSIS
Gets the members of the local administrators of the computer
and outputs the result to a CSV file.
.PARAMETER Computers
Specifies the Computer names of devices to query
.INPUTS
System.String. Get-LocalAdmins can accept a string value to
determine the Computers parameter.
<#
Step 1 - (on a non-DC)
Add-WindowsFeature RSAT-AD-PowerShell
Step 2 - Create a Security group and add all the hostnames you will use the gMSA on.
These are the computers permitted to retrieve the password from AD
#>
$gMSA_Name = 'svc_sql'
$gMSA_FQDN = 'svc_sql.hall.test'
# Getting all the hostnames from the group
$labName = 'TestLab'
$domain = 'test.lab'
$adminAcct = 'Administrator'
$adminPass = 'YourPasswordHere'
$labsources = "D:\LabSources"
#Create an empty lab template and define where the lab XML files and the VMs will be stored
New-LabDefinition -Name $labName -DefaultVirtualizationEngine HyperV
#Network definition
#1
Get-Service | Where-object { $_.Status -eq 'Running' -and $_.name -like 's*'}
#2
Get-Service -name s*| Where-object { $_.Status -eq 'Running'}
#1
Measure-Command -Expression {Get-Service | Where-object { $_.Status -eq 'Running' -and $_.name -like 's*'}}
#2
Measure-Command -Expression {Get-Service -name s*| Where-object { $_.Status -eq 'Running'}}