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 / 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'
@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 / 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 / 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 / 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 / Move-ADGroupMemberofToMember.ps1
Last active November 8, 2015 03:15
Single Domain support Move-ADGroupMemberofToMember
function Move-ADGroupMemberofToMember {
<#
.SYNOPSIS
Moves all Member Of Groups 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 Identity
Specify the group to run the cmdlet against.
.EXAMPLE
$parms = @{
'class'='Win32_LogicalDisk';
'computername'='DESKTOP';
'filter'='drivetype=3';
}
Get-WmiObject @parms
@duffney
duffney / Disable-ADComputer.ps1
Created November 7, 2015 21:22
Disables Computers and moves them to the specified OU.
function Disable-ADComputer {
<#
.SYNOPSIS
Disables Computers and moves them to the specified OU.
.DESCRIPTION
Take string or object input for computers then disables each one and moves to the specified ou
then outputs errors to a log file.
.PARAMETER Identity
Name of computer or computers
.PARAMETER DisabledOU
@duffney
duffney / Copy-SQLTable.ps1
Created September 19, 2015 15:59
Copy-SQLTable.ps1
function Copy-SQLTable {
<#
.SYNOPSIS
Copies a table from a source database and inserts it into the target database.
.DESCRIPTION
Takes all the data from the source database and inserts it into the target database with the same name.
.PARAMETER TableName
Specifies the table name to be copied from the source and inserted into the target.
.PARAMETER SourceServer
Specifies source server DNS name and instance, use ServerName\InstanceName.
@duffney
duffney / Config_SMTP_DSC.ps1
Last active August 29, 2015 00:47
Config_SMTP_DSC.ps1
configuration SMTP {
Node HTTPComputers {
WindowsFeature SMTP{
Name = 'SMTP-Server'
Ensure = 'Present'
}
}
}