Skip to content

Instantly share code, notes, and snippets.

View mczerniawski's full-sized avatar

mczerniawski mczerniawski

View GitHub Profile
function Get-CloudFlareFullZonesConfiguration {
[CmdletBinding()]
param(
[Parameter(Mandatory = $true, HelpMessage = 'Provide your CloudFlare API token',
ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[ValidateNotNullOrEmpty()]
[string]
$CloudFlareAPIToken,
$CloudFlareAPIToken = 'YOURTOKENGOESHERE'
$CloudFlareEmailAddress = 'YOUREMAIL AKA YOUR LOGIN'
$CloudFlareBaseUrl = 'https://api.cloudflare.com/client/v4/zones'
$CloudFlareHeaders = @{
'X-Auth-Key' = $CloudFlareAPIToken
'X-Auth-Email' = $CloudFlareEmailAddress
}
function Get-PrivilegedUsers {
<#
.SYNOPSIS
Returns all users belonging to Privileged Groups in Domain
.DESCRIPTION
Will return all members of Groups with 'AdminCount=1'. Can target other domains - require ComputerName and Credential parameter then.
.PARAMETER ComputerName
Domain Controller of another domain. Provide FQDN name
Function Get-PrivilegedGroupChanges {
<#
.SYNOPSIS
Will check for changes in Privileged Groups using Replication Metadata
.DESCRIPTION
Will return all members of Groups with 'AdminCount=1' that changed within last $Hours. Can target other domains - require ComputerName and Credential parameter then.
.PARAMETER ComputerName
Domain Controller of another domain. Provide FQDN name
function Get-ClusterCSVUsage {
<#
.SYNOPSIS
Retrieves CSV detailed information from Cluster
.DESCRIPTION
Will connect to cluster using Invoke-Command (to allow use of optional Credential Parameter) and retrieve detailed information on any CSV found
.PARAMETER Cluster
Cluster Name or array of Cluster Names
$PlasterTemplatePath = 'Path to PPoshModule template folder' #Path to where you've downloaded this module
$DestinationPath = 'C:\AdminTools\ModuleTest1' #Path to your git repository folder
Invoke-Plaster -TemplatePath $PlasterTemplatePath -DestinationPath $DestinationPath
____ _ _
| _ \| | __ _ ___| |_ ___ _ __
| |_) | |/ _` / __| __/ _ \ '__|
| __/| | (_| \__ \ || __/ |
|_| |_|\__,_|___/\__\___|_|
v1.1.3
==================================================
Author (Mateusz Czerniawski):
Name of your module: TestModule1
Version Number (0.0.1):
function Get-ClusterNodeMemory {
<#
.Synopsis
Get the available memory of each node in a cluster.
.DESCRIPTION
Get the available memory of each node in a cluster particularly for Hyper-V.
.PARAMETER Cluster
Provide Cluster Name. Will accept an array of cluter names
$HyperVHosts = @('NodeHV1','NodeHV2')
$IPAddress = '10.2.3'
$SelectObjectFilter = @(
@{name = 'VMName'; e={$PSItem.VMName}},
@{name = 'ComputerName';e={$PSItem.ComputerName}},
@{name = 'IPAddress';e={$PSItem.IPAddresses}},
@{name = 'SwitchName';e={$PSItem.SwitchName}},
@{name = 'MacAddress';e={$Psitem.MacAddress}}
)
$HyperVHosts = @('Cluster1','Node1','Node2')
$VMs = Get-VM -ComputerName $HyperVHosts | ForEach-Object {
Write-Host "Procesing VM {$($PSItem.VMName)}"
Write-Host "Getting VM {$($PSItem.VMName)} disk information"
$disks = Get-VHD -VMId $PSItem.VMId -ComputerName $PSItem.ComputerName
$diskCount = $disks | Measure | Select-Object -ExpandProperty Count
$diskCurrentSize = $disks | Measure-Object -Sum -Property FileSize | Select-Object -ExpandProperty Sum
$diskMaximumSize = $disks | Measure-Object -Sum -Property Size | Select-Object -ExpandProperty Sum
[pscustomobject]@{