Skip to content

Instantly share code, notes, and snippets.

View duffney's full-sized avatar
⌨️
Coding

Josh Duffney duffney

⌨️
Coding
View GitHub Profile
@duffney
duffney / Move-ADGroupMemberofToMember.ps1
Last active July 24, 2016 18:12
MultiDomain Move-ADGroupMemberofToMember
function Move-ADGroupMemberofToMember {
<#
.SYNOPSIS
Moves all Member Of objects to the Members section of an Active Directory group.
.DESCRIPTION
Queries an Active Directory group for all Member Of groups then add them to the members section
and removes them from the member of section of the active directory group.
.PARAMETER TargetGroup
Specify the group to run the cmdlet against.
.EXAMPLE
@duffney
duffney / FindandRenameNetworkAdapters.ps1
Created November 20, 2015 02:24
Find and Rename Network Adapters for setting up a Gateway Router on Windows Server
#Find External DHCP enabled interface
$External = (Get-NetIPAddress -AddressFamily IPv4).Where{$_.PrefixOrigin -eq 'Dhcp'}
#Rename DHCP adpter to External
Rename-NetAdapter -Name $External.InterfaceAlias -NewName 'External'
#Find Internal adpater
$Internal = (Get-NetIPAddress -AddressFamily IPv4).Where{$_.PrefixOrigin -ne 'Dhcp' -and $_.InterfaceAlias -notmatch 'Loopback'}
Rename-NetAdapter -Name $Internal.InterfaceAlias -NewName 'Internal'
@duffney
duffney / Create-PullServerModule.ps1
Last active June 11, 2018 15:00
Create-PullServerModule.ps1
$source = "C:\LabResources\xTimeZone"
$destination = "C:\temp"
$Version = (Get-ChildItem -Path $source -Depth 1).Name
$ResoureName = (Get-ChildItem -Path $source -Depth 1).Parent.Name
$ModuleName = $ResoureName+'_'+$Version
New-Item -Path ($destination+'\'+$ModuleName) -ItemType Directory
@duffney
duffney / ConvertTo-DSCPullArchive.ps1
Created December 1, 2015 15:57
Converts DSC resources to an archive .zip file for DSC Pull server use.
function ConvertTo-DSCPullArchive
{
<#
.Synopsis
Converts PowerShell Modules to compressed .zip files.
.DESCRIPTION
Converts PowerShell Modules to compressed .zip files
used by Desired State Configuraiton pull servers.
.PARAMETER Source
Specifies the source location of a PowerShell module.
@duffney
duffney / CreateHyperVNetworkAdapters.ps1
Last active December 4, 2015 14:45
Create Hyper-V Network Adapters
#Get Net Adapter Names
$NetAdapterName = (Get-NetAdapter).Name
#Create the External Hyper-V Switch
New-VMSwitch -NetAdapterName $NetAdapterName[0] -Name 'External'
#Create the Internal Hyper-V Switch
New-VMSwitch -SwitchType Internal -Name 'Internal'
$Name = 'VyOS'
$SwitchName = 'Internal'
$HardDiskSize = 2GB
$HDPath = 'E:\Hyper-V\Virtual Hard Disks'+'\'+$Name+'.vhdx'
$Generation = '1'
$ISO_Path = 'D:\ISOs\vyos-1.1.6-amd64.iso'
New-VM -Name $Name -SwitchName $SwitchName `
-NewVHDSizeBytes $HardDiskSize `
-NewVHDPath $HDPath -Generation $Generation -MemoryStartupBytes 512MB
Register-PSRepository -Name myNuGetSource -SourceLocation 'https://www.myget.org/F/powershellgetdemo/api/v2' -PublishLocation 'https://www.myget.org/F/powershellgetdemo/api/v2/Packages' -InstallationPolicy Trusted
Invoke-Command -ComputerName S2 -ScriptBlock {Find-Module xAdcsDeployment,xNetworking,xComputerManagement,xTimeZone | Install-Module -Confirm:$false -Verbose}
Configuration CertificateAuthority
{
Import-DscResource -ModuleName xAdcsDeployment,PSDesiredStateConfiguration,xNetworking,xComputerManagement,xTimeZone
Node $AllNodes.Where{$_.Role -eq "PKI"}.Nodename
{
xTimeZone SystemTimeZone {
TimeZone = 'Central Standard Time'
IsSingleInstance = 'Yes'
Invoke-Command -Computername s3 {Get-Childitem Cert:\LocalMachine\My}