Downloads:
32,544
Downloads of v 1.0.9-alpha6:
450
Last Update:
09 Jun 2015
Package Maintainer(s):
Software Author(s):
- SEEK Ltd.
Tags:
admin dsc- Software Specific:
- Software Site
- Software License
- Package Specific:
- Package outdated?
- Package broken?
- Contact Maintainers
- Contact Site Admins
- Software Vendor?
- Report Abuse
- Download
SEEK DSC Networking
This is a prerelease version of SEEK DSC Networking.
- 1
- 2
- 3
1.0.9-alpha6 | Updated: 09 Jun 2015
- Software Specific:
- Software Site
- Software License
- Package Specific:
- Package outdated?
- Package broken?
- Contact Maintainers
- Contact Site Admins
- Software Vendor?
- Report Abuse
- Download
Downloads:
32,544
Downloads of v 1.0.9-alpha6:
450
Maintainer(s):
Software Author(s):
- SEEK Ltd.
SEEK DSC Networking 1.0.9-alpha6
This is a prerelease version of SEEK DSC Networking.
Legal Disclaimer: Neither this package nor Chocolatey Software, Inc. are affiliated with or endorsed by SEEK Ltd. The inclusion of SEEK Ltd. trademark(s), if any, upon this webpage is solely to identify SEEK Ltd. goods or services and not for commercial purposes.
- 1
- 2
- 3
Some Checks Have Failed or Are Not Yet Complete
Not All Tests Have Passed
Validation Testing Unknown
Verification Testing Unknown
Scan Testing Successful:
No detections found in any package files
Deployment Method: Individual Install, Upgrade, & Uninstall
To install SEEK DSC Networking, run the following command from the command line or from PowerShell:
To upgrade SEEK DSC Networking, run the following command from the command line or from PowerShell:
To uninstall SEEK DSC Networking, run the following command from the command line or from PowerShell:
Deployment Method:
This applies to both open source and commercial editions of Chocolatey.
1. Enter Your Internal Repository Url
(this should look similar to https://community.chocolatey.org/api/v2/)
2. Setup Your Environment
1. Ensure you are set for organizational deployment
Please see the organizational deployment guide
2. Get the package into your environment
Option 1: Cached Package (Unreliable, Requires Internet - Same As Community)-
Open Source or Commercial:
- Proxy Repository - Create a proxy nuget repository on Nexus, Artifactory Pro, or a proxy Chocolatey repository on ProGet. Point your upstream to https://community.chocolatey.org/api/v2/. Packages cache on first access automatically. Make sure your choco clients are using your proxy repository as a source and NOT the default community repository. See source command for more information.
- You can also just download the package and push it to a repository Download
-
Open Source
-
Download the package:
Download - Follow manual internalization instructions
-
-
Package Internalizer (C4B)
-
Run: (additional options)
choco download seek-dsc-networking --internalize --version=1.0.9-alpha6 --pre --source=https://community.chocolatey.org/api/v2/
-
For package and dependencies run:
choco push --source="'INTERNAL REPO URL'"
- Automate package internalization
-
Run: (additional options)
3. Copy Your Script
choco upgrade seek-dsc-networking -y --source="'INTERNAL REPO URL'" --version="'1.0.9-alpha6'" --prerelease [other options]
See options you can pass to upgrade.
See best practices for scripting.
Add this to a PowerShell script or use a Batch script with tools and in places where you are calling directly to Chocolatey. If you are integrating, keep in mind enhanced exit codes.
If you do use a PowerShell script, use the following to ensure bad exit codes are shown as failures:
choco upgrade seek-dsc-networking -y --source="'INTERNAL REPO URL'" --version="'1.0.9-alpha6'" --prerelease
$exitCode = $LASTEXITCODE
Write-Verbose "Exit code was $exitCode"
$validExitCodes = @(0, 1605, 1614, 1641, 3010)
if ($validExitCodes -contains $exitCode) {
Exit 0
}
Exit $exitCode
- name: Install seek-dsc-networking
win_chocolatey:
name: seek-dsc-networking
version: '1.0.9-alpha6'
source: INTERNAL REPO URL
state: present
allow_prerelease: yes
See docs at https://docs.ansible.com/ansible/latest/modules/win_chocolatey_module.html.
chocolatey_package 'seek-dsc-networking' do
action :install
source 'INTERNAL REPO URL'
version '1.0.9-alpha6'
options '--prerelease'
end
See docs at https://docs.chef.io/resource_chocolatey_package.html.
cChocoPackageInstaller seek-dsc-networking
{
Name = "seek-dsc-networking"
Version = "1.0.9-alpha6"
Source = "INTERNAL REPO URL"
chocoParams = "--prerelease"
}
Requires cChoco DSC Resource. See docs at https://github.com/chocolatey/cChoco.
package { 'seek-dsc-networking':
ensure => '1.0.9-alpha6',
install_options => ['--prerelease'],
provider => 'chocolatey',
source => 'INTERNAL REPO URL',
}
Requires Puppet Chocolatey Provider module. See docs at https://forge.puppet.com/puppetlabs/chocolatey.
4. If applicable - Chocolatey configuration/installation
See infrastructure management matrix for Chocolatey configuration elements and examples.
This package was approved as a trusted package on 09 Jun 2015.
Custom DSC Resources for networking administration
<# NOTE: This SSL certificate request module is designed for Local Dev machines ONLY !!! #>
<#
Retrieves a SSL certificate for a Subject located on machine
#>
function Get-TargetResource
{
[CmdletBinding()]
[OutputType([System.Collections.Hashtable])]
param
(
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String]$Subject,
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String]$CertPath
)
Write-Verbose "Getting CERT"
$theCert = Get-ChildItem -path $CertPath | Where-Object {$_.Subject -eq $Subject}
#find the certificate and return
$certResult = @{
Subject = $Cert.Subject
Ensure = "Present"
SANs = $Cert.DnsNameList
OnlineCA = $Cert.Issuer
}
return $certResult
}
<#
Creates a SSL certificate for a Subject on machine if Present is ensured.
Removes SSL certificate for a Subject on machine if Absent is ensured.
#>
function Set-TargetResource
{
[CmdletBinding()]
param
(
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String]$Subject,
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String]$CertPath,
[ValidateSet("Present", "Absent")]
[string]$Ensure = "Present",
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String[]]$SANs,
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String]$OnlineCA
)
Write-Verbose "Setting CERT"
if($Ensure -eq "Present")
{
Write-Verbose "Creating CERT for $Subject"
#call certreq
$subjectDomain = $Subject.split(',')[0].split('=')[1]
if ($subjectDomain -match "\*.") {
$subjectDomain = $subjectDomain -replace "\*", "star"
}
$CertificateINI = "$subjectDomain.ini"
$CertificateREQ = "$subjectDomain.req"
$CertificateRSP = "$subjectDomain.rsp"
$CertificateCER = "$subjectDomain.cer"
### INI file generation
new-item -type file $CertificateINI -force
add-content $CertificateINI '[Version]'
add-content $CertificateINI 'Signature="$Windows NT$"'
add-content $CertificateINI ''
add-content $CertificateINI '[NewRequest]'
$temp = 'Subject="' + $Subject + '"'
add-content $CertificateINI $temp
add-content $CertificateINI 'Exportable=TRUE'
add-content $CertificateINI 'KeyLength=2048'
add-content $CertificateINI 'KeySpec=1'
add-content $CertificateINI 'KeyUsage=0xA0'
add-content $CertificateINI 'MachineKeySet=True'
add-content $CertificateINI 'ProviderName="Microsoft RSA SChannel Cryptographic Provider"'
add-content $CertificateINI 'ProviderType=12'
add-content $CertificateINI 'RequestType=CMC'
add-content $CertificateINI ''
add-content $CertificateINI '[RequestAttributes]'
add-content $CertificateINI 'CertificateTemplate="WebServer"'
add-content $CertificateINI ''
add-content $CertificateINI '[EnhancedKeyUsageExtension]'
add-content $CertificateINI 'OID=1.3.6.1.5.5.7.3.1'
add-content $CertificateINI ''
if ($SANs) {
add-content $CertificateINI '[Extensions]'
add-content $CertificateINI '2.5.29.17 = "{text}"'
foreach ($SAN in $SANs) {
$temp = '_continue_ = "dns=' + $SAN + '&"'
add-content $CertificateINI $temp
}
}
try
{
### Certificate request generation
if (test-path $CertificateREQ) {
del $CertificateREQ
}
Write-Verbose "Converting $CertificateINI to CSR: certreq -new $CertificateINI $CertificateREQ"
certreq -new $CertificateINI $CertificateREQ
### Online certificate request and import
if ($OnlineCA) {
if (test-path $CertificateCER) {del $CertificateCER}
if (test-path $CertificateRSP) {del $CertificateRSP}
Write-Verbose "Submitting: certreq -submit -config $OnlineCA $CertificateREQ $CertificateCER"
certreq -submit -config $OnlineCA $CertificateREQ $CertificateCER
Write-Verbose "Merging certificate response file and CSR together to generate SSL certificate: certreq -accept -config $OnlineCA $CertificateCER"
certreq -accept -config $OnlineCA $CertificateCER
}
Write-Verbose "Finished creating CERT for $Subject"
}
catch
{
$errorId = "CertReqFailure";
$errorCategory = [System.Management.Automation.ErrorCategory]::InvalidOperation;
$errorMessage = "CertGenerationFailure -f ${Name}";
$exception = New-Object System.InvalidOperationException $errorMessage ;
$errorRecord = New-Object System.Management.Automation.ErrorRecord $exception, $errorId, $errorCategory, $null
$PSCmdlet.ThrowTerminatingError($errorRecord)
}
Test-TargetResource $Subject $CertPath $Ensure $SANs $OnlineCA
}
else
{
Write-Verbose "Removing CERT for $Subject"
$theCert = Get-ChildItem -path $CertPath | Where-Object {$_.Subject -eq $Subject}
if ($theCert -ne $null)
{
$Thumbprint = $theCert.Thumbprint
Remove-Item -Path "$CertPath\$Thumbprint"
Write-Verbose "Successfully removed CERT for $Subject"
}
}
}
<#
Tests a SSL certificate for a Subject IS located on machine if Present is ensured.
Tests a SSL certificate for a Subject IS NOT located on machine if Absent is ensured.
#>
function Test-TargetResource
{
[CmdletBinding()]
[OutputType([System.Boolean])]
param
(
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String]$Subject,
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String]$CertPath,
[ValidateSet("Present", "Absent")]
[string]$Ensure = "Present",
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String[]]$SANs,
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String]$OnlineCA
)
Write-Verbose "Testing CERT"
#test that the cert is there
$theCert = Get-ChildItem -path $CertPath | Where-Object {$_.Subject -eq $Subject}
if ($theCert -ne $null -and $Ensure -eq "Present")
{
Write-Verbose "CERT Thumbprint is $theCert"
Write-Verbose "CERT is expected to be Present and is Present"
return $true
}
if ($theCert -eq $null -and $Ensure -eq "Absent")
{
Write-Verbose "CERT is expected to be Absent and is Absent"
return $true
}
return $false
}
# FUNCTIONS TO BE EXPORTED
Export-ModuleMember -function Get-TargetResource, Set-TargetResource, Test-TargetResource
function Get-TargetResource
{
[CmdletBinding()]
[OutputType([System.Collections.Hashtable])]
param
(
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[System.String]$Name
)
try
{
$advFirewallOutput = (Invoke-NetshAdvFirewall -Name $Name -Operation "show")
$firewallRuleExists = $advFirewallOutput -match "Rule Name:\s+$Name\s+"
}
catch
{
$firewallRuleExists = $false
}
if (-not $firewallRuleExists)
{
return @{
Name = $Name
Direction = $null
LocalPort = $null
Protocol = $null
Action = $null
Ensure = "Absent"
}
}
if ($advFirewallOutput -match "Direction:\s+(.+?)\s+")
{
$direction = switch ($Matches[1])
{
"in" {"Inbound"}
"out" {"Outbound"}
}
}
if ($advFirewallOutput -match "LocalPort:\s+(.+?)\s+")
{
$localport = $Matches[1]
}
if ($advFirewallOutput -match "Protocol:\s+(.+?)\s+")
{
$protocol = $Matches[1]
}
if ($advFirewallOutput -match "Action:\s+(.+?)\s+")
{
$action = $Matches[1]
}
return @{
Name = $Name
Direction = $direction
LocalPort = $localPort
Protocol = $protocol
Action = $action
Ensure = "Present"
}
}
function Set-TargetResource
{
[CmdletBinding(DefaultParameterSetName = "Absent")]
param
(
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[System.String]$Name,
[parameter(Mandatory=$true,ParameterSetName = "Present")]
[ValidateSet("Inbound","Outbound")]
[System.String]$Direction,
[parameter(Mandatory=$true,ParameterSetName = "Present")]
[ValidateNotNullOrEmpty()]
[System.String]$LocalPort,
[parameter(Mandatory=$true,ParameterSetName = "Present")]
[ValidateSet("TCP","UDP")]
[System.String]$Protocol,
[parameter(Mandatory=$true,ParameterSetName = "Present")]
[ValidateSet("Allow","Block", "Bypass")]
[System.String]$Action,
[parameter(Mandatory=$false,ParameterSetName = "Present")]
[parameter(Mandatory=$true,ParameterSetName = "Absent")]
[ValidateSet("Present","Absent")]
[System.String]
$Ensure = "Present"
)
if ($Ensure -eq "Present")
{
New-NetFirewallRule -Name $Name `
-Direction $Direction `
-LocalPort $LocalPort `
-Protocol $Protocol `
-Action $Action
}
else
{
Remove-NetFirewallRule -Name $Name
}
}
function Test-TargetResource
{
[CmdletBinding(DefaultParameterSetName = "Absent")]
param
(
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[System.String]$Name,
[parameter(Mandatory=$true,ParameterSetName = "Present")]
[ValidateSet("Inbound","Outbound")]
[System.String]$Direction,
[parameter(Mandatory=$true,ParameterSetName = "Present")]
[ValidateNotNullOrEmpty()]
[System.String]$LocalPort,
[parameter(Mandatory=$true,ParameterSetName = "Present")]
[ValidateSet("TCP","UDP")]
[System.String]$Protocol,
[parameter(Mandatory=$true,ParameterSetName = "Present")]
[ValidateSet("Allow","Block", "Bypass")]
[System.String]$Action,
[parameter(Mandatory=$false,ParameterSetName = "Present")]
[parameter(Mandatory=$true,ParameterSetName = "Absent")]
[ValidateSet("Present","Absent")]
[System.String]
$Ensure = "Present"
)
$firewallRule = Get-TargetResource -Name $Name
if ($Ensure -eq "Absent" -and $firewallRule.Ensure -eq "Absent")
{
return $true
}
if ($Ensure -eq "Present" `
-and $firewallRule.Ensure -eq "Present" `
-and $firewallRule.Direction -eq $Direction `
-and $firewallRule.LocalPort -eq $LocalPort `
-and $firewallRule.Protocol -eq $Protocol `
-and $firewallRule.Action -eq $Action)
{
return $true
}
return $false
}
function New-NetFirewallRule
{
param
(
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[String]$Name,
[String]$Protocol,
[String]$LocalPort,
[ValidateSet("Inbound", "Outbound")]
[String]$Direction,
[ValidateSet("Allow", "Block", "Bypass")]
[String]$Action
)
Invoke-NetshAdvFirewall -Name $Name `
-Operation "add" `
-Protocol $Protocol `
-LocalPort $LocalPort `
-Direction $Direction `
-Action $Action
}
function Remove-NetFirewallRule
{
param
(
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[String]$Name
)
Invoke-NetshAdvFirewall -Name $Name -Operation "del"
}
function Invoke-NetshAdvFirewall
{
[CmdletBinding()]
[OutputType([System.String])]
param
(
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[String]$Name,
[parameter(Mandatory = $true)]
[ValidateSet("add","del","show")]
[String]$Operation,
[String]$Protocol,
[String]$LocalPort,
[ValidateSet("Inbound", "Outbound")]
[String]$Direction,
[ValidateSet("Allow", "Block", "Bypass")]
[String]$Action
)
$argumentList = @(
'advfirewall', 'firewall', $Operation, 'rule',
"name=""${Name}"""
)
if ($Direction)
{
$dir = switch ($Direction)
{
"Inbound" {"in"}
"Outbound" {"out"}
}
$argumentList += "dir=$dir"
}
if ($Protocol)
{
$argumentList += "protocol=$Protocol"
}
if ($LocalPort)
{
$argumentList += "localport=$LocalPort"
}
if ($Action)
{
$argumentList += "action=$Action"
}
$outputPath = "${env:TEMP}\netsh.out"
$process = Start-Process netsh -ArgumentList $argumentList -Wait -NoNewWindow -RedirectStandardOutput $outputPath -Passthru
if ($process.ExitCode -ne 0) { throw "Error performing operation '$Operation' for firewall rule"}
return ((Get-Content $outputPath) -join "`n")
}
Export-ModuleMember -function Get-TargetResource, Set-TargetResource, Test-TargetResource
<#######################################################################################
# MSDSCPack_IPAddress : DSC Resource that will set/test/get the current IP
# Address, by accepting values among those given in MSDSCPack_IPAddress.schema.mof
#######################################################################################>
######################################################################################
# The Get-TargetResource cmdlet.
# This function will get the present list of IP Address DSC Resource schema variables on the system
######################################################################################
function Get-TargetResource
{
param
(
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String]$IPAddress,
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String]$NodeName
)
Write-Warning "SEEK_cIPAddress resource is obsolete, please use SEEK_cStaticIpAddress"
$returnValue = @{
}
$returnValue
}
######################################################################################
# The Set-TargetResource cmdlet.
# This function will set a new IP Address in the current node
######################################################################################
function Set-TargetResource
{
param
(
#IP Address that has to be set
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String]$IPAddress,
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String]$NodeName
)
Write-Warning "SEEK_cIPAddress resource is obsolete, please use SEEK_cStaticIpAddress"
ValidateProperties @PSBoundParameters
}
######################################################################################
# The Test-TargetResource cmdlet.
# This will test if the given IP Address is among the current node's IP Address collection
######################################################################################
function Test-TargetResource
{
param
(
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String]$IPAddress,
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String]$NodeName
)
Write-Warning "SEEK_cIPAddress resource is obsolete, please use SEEK_cStaticIpAddress"
$result = ValidateProperties @PSBoundParameters
if ($result -eq $false)
{
$errorId = "WebsiteBindingConflictOnStart";
$errorCategory = [System.Management.Automation.ErrorCategory]::InvalidResult
$errorMessage = "IPAddress $IPAddress not found..."
$exception = New-Object System.InvalidOperationException $errorMessage
$errorRecord = New-Object System.Management.Automation.ErrorRecord $exception, $errorId, $errorCategory, $null
$PSCmdlet.ThrowTerminatingError($errorRecord);
}
$result
}
#######################################################################################
# Helper function that validates the IP Address properties. If the switch parameter
# "Apply" is set, then it will set the properties after a test
#######################################################################################
function ValidateProperties
{
param
(
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String]$IPAddress,
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String]$NodeName,
[Switch]$Apply
)
$ip = $IPAddress
if(!([System.Net.Ipaddress]::TryParse($ip, [ref]0)))
{
throw "IP Address *$IPAddress* is not in the correct format. Please correct the ipaddress in the configuration and try again"
}
try
{
#Write-Verbose -Message "Checking the IPAddress ..."
$Networks = Get-WmiObject Win32_NetworkAdapterConfiguration -ComputerName $NodeName | ? {$_.IPEnabled}
foreach($Network in $Networks)
{
if ($Network.IPAddress.Contains($IPAddress))
{
return $true
break;
}
}
Write-Verbose -Message "IPAddressFound $IPAddressFound"
return $false
}
catch
{
Write-Verbose -Message $_
throw "Can not set or find valid IPAddress using InterfaceAlias $InterfaceAlias and AddressFamily $AddressFamily"
}
}
# FUNCTIONS TO BE EXPORTED
Export-ModuleMember -function Get-TargetResource, Set-TargetResource, Test-TargetResource
# NOTE: Supports IPv4 addresses only
function Get-TargetResource
{
[CmdletBinding()]
[OutputType([System.Collections.Hashtable])]
param
(
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[System.String]$IpAddress
)
$networkAdapterConfiguration = Get-NetworkAdapterConfigurationByIpAddress $IpAddress
if ($networkAdapterConfiguration -eq $null)
{
return @{
IpAddress = $IpAddress
Interface = $null
SubnetMask = $null
DHCPEnabled = $null
Ensure = "Absent"
}
}
$networkAdapter = Get-NetworkAdapterByIndex $networkAdapterConfiguration.Index
$ipAddressList = $networkAdapterConfiguration.IPAddress | Where-IPv4Address
$ipSubnetList = $networkAdapterConfiguration.IPSubnet | Where-IPv4Subnet
$ipAddressIndex = $ipAddressList.IndexOf($IpAddress)
return @{
IpAddress = $IpAddress
Interface = $networkAdapter.NetConnectionID
SubnetMask = @($ipSubnetList)[$ipAddressIndex]
DHCPEnabled = $networkAdapterConfiguration.DHCPEnabled
Ensure = "Present"
}
}
function Set-TargetResource
{
[CmdletBinding()]
param
(
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[System.String]$IpAddress,
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[System.String]$Interface,
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[System.String]$SubnetMask,
[ValidateSet("Present","Absent")]
[System.String]
$Ensure = "Present"
)
if(!([System.Net.Ipaddress]::TryParse($IpAddress, [ref]0))) { throw "IP Address ""$IpAddress"" is invalid"}
if(!([System.Net.Ipaddress]::TryParse($SubnetMask, [ref]0))) { throw "SubnetMask ""$SubnetMask"" is invalid"}
if ($Ensure -eq "Absent")
{
Remove-IpAddress -IpAddress $IpAddress -Interface $Interface
}
else
{
Add-IpAddress -IpAddress $IpAddress -Interface $Interface -SubnetMask $SubnetMask
}
}
function Test-TargetResource
{
[CmdletBinding()]
param
(
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[System.String]$IpAddress,
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[System.String]$Interface,
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[System.String]$SubnetMask,
[ValidateSet("Present","Absent")]
[System.String]
$Ensure = "Present"
)
$existingIpAddress = Get-TargetResource $IpAddress
if ($Ensure -eq "Present" -and `
$existingIpAddress -ne $null -and `
$existingIpAddress.Interface -eq $Interface -and `
$existingIpAddress.SubnetMask -eq $SubnetMask -and `
$existingIpAddress.Ensure -eq $Ensure -and `
$existingIpAddress.DHCPEnabled -eq $false)
{
return $true
}
elseif ($Ensure -eq "Absent" -and `
$existingIpAddress.Ensure -eq $Ensure)
{
return $true
}
return $false
}
function Add-IpAddress
{
param
(
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[System.String]$IpAddress,
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[System.String]$Interface,
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[System.String]$SubnetMask
)
$networkAdapterConfiguration = Get-NetworkAdapterConfigurationByInterface $Interface
if (Test-IpAddressBound -IpAddress $IpAddress -Index $networkAdapterConfiguration.Index -SubnetMask $SubnetMask) { return }
if (Test-IpAddressBound $IpAddress)
{
Remove-IpAddress -IpAddress $IpAddress
}
$ipAddressList = $networkAdapterConfiguration.IPAddress + @($IpAddress) | Where-IPv4Address
$ipSubnetList = $networkAdapterConfiguration.IPSubnet + @($SubnetMask) | Where-IPv4Subnet
Enable-Static -NetworkAdapterConfiguration $networkAdapterConfiguration `
-IpAddresses $ipAddressList `
-IpSubnets $ipSubnetList
}
function Remove-IpAddress
{
param
(
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[System.String]$IpAddress,
[parameter(Mandatory = $false)]
[System.String]$Interface = $null
)
$networkAdapterConfiguration = $null
if ($Interface)
{
$networkAdapterConfiguration = Get-NetworkAdapterConfigurationByInterface $Interface
}
else
{
$networkAdapterConfiguration = Get-NetworkAdapterConfigurationByIpAddress $IpAddress
}
$ipAddressList = [System.Collections.ArrayList]@($networkAdapterConfiguration.IPAddress | Where-IPv4Address)
$ipSubnetList = [System.Collections.ArrayList]@($networkAdapterConfiguration.IPSubnet | Where-IPv4Subnet)
$ipAddressIndex = $ipAddressList.IndexOf($IpAddress)
if ($ipAddressIndex -lt 0) {return}
$ipAddressList.RemoveAt($ipAddressIndex)
$ipSubnetList.RemoveAt($ipAddressIndex)
if ($ipAddressList.Length -gt 0)
{
Enable-Static -NetworkAdapterConfiguration $networkAdapterConfiguration `
-IpAddresses ([Object[]]$ipAddressList) `
-IpSubnets ([Object[]]$ipSubnetList)
}
else
{
# Adapter is no longer bound to any IP addresses
# Reverting adapter to DHCP
Enable-DHCP -NetworkAdapterConfiguration $networkAdapterConfiguration
}
}
function Where-IPv4Address
{
[CmdletBinding()]
param
(
[parameter(Mandatory = $true, ValueFromPipeline = $true)]
[String]
$InputObject
)
process
{
if ($InputObject -notmatch ":")
{
Write-Output $InputObject
}
}
}
function Where-IPv4Subnet
{
[CmdletBinding()]
param
(
[parameter(Mandatory = $true, ValueFromPipeline = $true)]
[String]
$InputObject
)
process
{
if ($InputObject -match "\d+\.\d+\.\d+\.\d+")
{
Write-Output $InputObject
}
}
}
function Get-NetworkAdapterByIndex
{
param
(
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[Int32]$Index
)
$networkAdapter = Get-WmiObject Win32_NetworkAdapter | ? {$_.Index -eq $Index}
$results = $networkAdapter | measure
if ($results.count -le 0)
{
throw "Could not find a network adapter with index ""$Index"""
}
elseif ($results.count -gt 1)
{
$matchingAdapters = ($networkAdapter | % Path) -join ", "
throw "Multiple network adapters match the index ""$Index"" {$matchingAdapters}"
}
return ($networkAdapter | Select-Object -First 1)
}
function Get-NetworkAdapterByInterface
{
param
(
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[System.String]$Interface
)
$networkAdapter = Get-WmiObject Win32_NetworkAdapter | ? {$_.NetConnectionID -eq $Interface}
$results = $networkAdapter | measure
if ($results.count -le 0)
{
throw "Could not find a network adapter matching ""$Interface"""
}
elseif ($results.count -gt 1)
{
$matchingAdapters = ($networkAdapter | % Path) -join ", "
throw "Multiple network adapters match the interface ""$Interface"" {$matchingAdapters}"
}
return ($networkAdapter | Select-Object -First 1)
}
function Get-NetworkAdapterConfigurationByInterface
{
param
(
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[System.String]$Interface
)
$networkAdapter = Get-NetworkAdapterByInterface $Interface
return (Get-WmiObject Win32_NetworkAdapterConfiguration | ? {$_.Index -eq $networkAdapter.Index} | Select-Object -First 1)
}
function Get-NetworkAdapterConfigurationByIpAddress
{
param
(
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[System.String]$IpAddress
)
$networkAdapterConfiguration = Get-WmiObject Win32_NetworkAdapterConfiguration | ? {$_.IPAddress -contains $IpAddress}
$results = $networkAdapterConfiguration | measure
if ($results.count -gt 1)
{
$matchingAdapters = ($networkAdapterConfiguration | % Path) -join ", "
throw "IP Address ""$IpAddress"" is bound to multiple network adapters {$matchingAdapters}"
}
return ($networkAdapterConfiguration | Select-Object -First 1)
}
function Test-IpAddressBound
{
[OutputType([Boolean])]
param
(
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[System.String]$IpAddress,
[parameter(Mandatory = $false)]
[ValidateNotNullOrEmpty()]
[Int32]$Index,
[parameter(Mandatory = $false)]
[ValidateNotNullOrEmpty()]
[System.String]$SubnetMask
)
$networkAdapterConfiguration = Get-WmiObject Win32_NetworkAdapterConfiguration | ? {$_.IPAddress -contains $IpAddress}
if ($Index)
{
$networkAdapterConfiguration = $networkAdapterConfiguration | ? {$_.Index -eq $Index}
}
if ($SubnetMask)
{
$networkAdapterConfiguration = $networkAdapterConfiguration | ? {$_.IPSubnet[$_.IPAddress.IndexOf($IpAddress)] -eq $SubnetMask}
}
$results = $networkAdapterConfiguration | measure
if ($results.count -le 0) { return $false } else { return $true }
}
function Enable-Static
{
[CmdletBinding()]
param
(
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[System.String[]]$IpAddresses,
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[System.String[]]$IpSubnets,
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[Object]$NetworkAdapterConfiguration
)
$result = $NetworkAdapterConfiguration.EnableStatic($IpAddresses, $IpSubnets)
if ($result.ReturnValue -ne 0) { throw "Failed to enable static IP addresses on network adapter with index ""$($NetworkAdapterConfiguration.Index)"" {$($IpAddresses -join ", ")}"}
}
function Enable-DHCP
{
[CmdletBinding()]
param
(
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[Object]$NetworkAdapterConfiguration
)
$result = $NetworkAdapterConfiguration.EnableDHCP()
if ($result.ReturnValue -ne 0) { throw "Failed to enable DHCP on network adapter with index ""$($NetworkAdapterConfiguration.Index)"""}
}
Export-ModuleMember -function Get-TargetResource, Set-TargetResource, Test-TargetResource
function Get-TargetResource
{
[CmdletBinding()]
[OutputType([System.Collections.Hashtable])]
param
(
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[String]$Protocol = "http",
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[String]$Hostname = "*",
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[String]$Port
)
$url = Get-Url $Protocol $Hostname $Port
$urlAclOutput = (Invoke-NetshUrlAcl -Protocol $Protocol -Operation "show" -Url $url)
$urlReservationExists = $urlAclOutput -match "User:\s(.+?)\s"
if (!$urlReservationExists)
{
return @{
Protocol = $Protocol
Hostname = $Hostname
Port = $Port
User = $null
Ensure = "Absent"
}
}
$user = $Matches[1]
return @{
Protocol = $Protocol
Hostname = $Hostname
Port = $Port
User = $user
Ensure = "Present"
}
}
function Set-TargetResource
{
[CmdletBinding(DefaultParameterSetName = "Absent")]
param
(
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[String]$Protocol = "http",
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[String]$Hostname = "*",
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[String]$Port,
[parameter(Mandatory=$true,ParameterSetName = "Present")]
[ValidateNotNullOrEmpty()]
[String]$User,
[parameter(Mandatory=$false,ParameterSetName = "Present")]
[parameter(Mandatory=$true,ParameterSetName = "Absent")]
[ValidateSet("Present","Absent")]
[System.String]
$Ensure = "Present"
)
if ($Ensure -eq "Present")
{
New-UrlReservation -Protocol $Protocol -Hostname $Hostname -Port $Port -User $User
}
else
{
Remove-UrlReservation -Protocol $Protocol -Hostname $Hostname -Port $Port
}
}
function Test-TargetResource
{
[CmdletBinding(DefaultParameterSetName = "Absent")]
param
(
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[String]$Protocol = "http",
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[String]$Hostname = "*",
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[String]$Port,
[parameter(Mandatory=$true,ParameterSetName = "Present")]
[ValidateNotNullOrEmpty()]
[String]$User,
[parameter(Mandatory=$false,ParameterSetName = "Present")]
[parameter(Mandatory=$true,ParameterSetName = "Absent")]
[ValidateSet("Present","Absent")]
[System.String]
$Ensure = "Present"
)
$urlReservation = Get-TargetResource -Protocol $Protocol -Hostname $Hostname -Port $Port
if ($Ensure -eq "Absent" -and $urlReservation.Ensure -eq "Absent")
{
return $true
}
if ($Ensure -eq "Present" `
-and $urlReservation.Ensure -eq "Present" `
-and $urlReservation.Protocol -eq $Protocol `
-and $urlReservation.Hostname -eq $Hostname `
-and $urlReservation.Port -eq $Port `
-and $urlReservation.User -eq $User)
{
return $true
}
return $false
}
function New-UrlReservation
{
[CmdletBinding()]
param
(
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[String]$Protocol = "http",
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[String]$Hostname = "*",
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[String]$Port,
[ValidateNotNullOrEmpty()]
[String]$User
)
$url = Get-Url $Protocol $Hostname $Port
Invoke-NetshUrlAcl -Protocol $Protocol -Operation "add" -Url $url -User $User
}
function Remove-UrlReservation
{
[CmdletBinding()]
param
(
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[String]$Protocol = "http",
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[String]$Hostname = "*",
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[String]$Port
)
$url = Get-Url $Protocol $Hostname $Port
Invoke-NetshUrlAcl -Protocol $Protocol -Operation "del" -Url $url
}
function Get-Url
{
[CmdletBinding()]
param
(
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[String]$Protocol = "http",
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[String]$Hostname = "*",
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[String]$Port
)
return "${Protocol}://${Hostname}:${Port}/"
}
function Invoke-NetshUrlAcl
{
[CmdletBinding()]
[OutputType([System.String])]
param
(
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[String]$Protocol = "http",
[parameter(Mandatory = $true)]
[ValidateSet("add","del","show")]
[String]$Operation,
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[String]$Url,
[String]$User
)
$argumentList = @(
$Protocol, $Operation, 'urlacl',
"url=""${Url}"""
)
if ($user)
{
$argumentList += "user=""${User}"""
}
$outputPath = "${env:TEMP}\netsh.out"
$process = Start-Process netsh -ArgumentList $argumentList -Wait -NoNewWindow -RedirectStandardOutput $outputPath -Passthru
if ($process.ExitCode -ne 0) { throw "Error performing operation '${Operation}' for reserved url"}
return ((Get-Content $outputPath) -join "`n")
}
Export-ModuleMember -function Get-TargetResource, Set-TargetResource, Test-TargetResource
try
{
$DSCResourcesRoot = Join-Path $env:ProgramFiles "WindowsPowerShell\Modules"
$DSCResourceTarget = Join-Path $env:chocolateyPackageFolder "lib"
Get-ChildItem $DSCResourceTarget | Foreach-Object { cmd /c rmdir "$DSCResourcesRoot\$_" }
} catch {
throw $_.Exception
}
Log in or click on link to see number of positives.
In cases where actual malware is found, the packages are subject to removal. Software sometimes has false positives. Moderators do not necessarily validate the safety of the underlying software, only that a package retrieves software from the official distribution point and/or validate embedded software against official distribution point (where distribution rights allow redistribution).
Chocolatey Pro provides runtime protection from possible malware.
Add to Builder | Version | Downloads | Last Updated | Status |
---|---|---|---|---|
SEEK DSC Networking 2.0.0.20230301-alpha9 | 102 | Tuesday, January 3, 2023 | Exempted | |
SEEK DSC Networking 2.0.0-alpha9 | 559 | Thursday, July 30, 2015 | Approved | |
SEEK DSC Networking 2.0.0-alpha7 | 480 | Friday, May 1, 2015 | Approved | |
SEEK DSC Networking 2.0.0-alpha6 | 440 | Wednesday, April 22, 2015 | Approved | |
SEEK DSC Networking 2.0.0-alpha5 | 486 | Tuesday, April 21, 2015 | Approved | |
SEEK DSC Networking 2.0.0-alpha4 | 422 | Tuesday, April 21, 2015 | Approved | |
SEEK DSC Networking 2.0.0-alpha2 | 450 | Tuesday, February 24, 2015 | Approved | |
SEEK DSC Networking 2.0.0-alpha1 | 427 | Monday, February 23, 2015 | Approved | |
SEEK DSC Networking 1.0.10 | 1834 | Thursday, July 30, 2015 | Approved | |
SEEK DSC Networking 1.0.9-alpha6 | 450 | Tuesday, June 9, 2015 | Approved | |
SEEK DSC Networking 1.0.9-alpha5 | 411 | Tuesday, June 9, 2015 | Approved | |
SEEK DSC Networking 1.0.9-alpha4 | 374 | Tuesday, June 9, 2015 | Approved | |
SEEK DSC Networking 1.0.9-alpha3 | 438 | Tuesday, May 26, 2015 | Approved | |
SEEK DSC Networking 1.0.9-alpha2 | 416 | Tuesday, May 26, 2015 | Approved | |
SEEK DSC Networking 1.0.9-alpha1 | 417 | Friday, May 22, 2015 | Approved | |
SEEK DSC Networking 1.0.4 | 507 | Friday, May 1, 2015 | Approved | |
SEEK DSC Networking 1.0.3 | 465 | Wednesday, April 22, 2015 | Approved | |
SEEK DSC Networking 1.0.2 | 400 | Tuesday, April 21, 2015 | Approved | |
SEEK DSC Networking 1.0.0.87 | 593 | Sunday, February 22, 2015 | Approved | |
SEEK DSC Networking 1.0.0.77 | 471 | Sunday, January 25, 2015 | Approved | |
SEEK DSC Networking 1.0.0.76 | 440 | Wednesday, January 14, 2015 | Approved | |
SEEK DSC Networking 1.0.0.75 | 669 | Tuesday, December 2, 2014 | Approved | |
SEEK DSC Networking 1.0.0.74 | 543 | Sunday, November 9, 2014 | Approved | |
SEEK DSC Networking 1.0.0.73 | 424 | Friday, November 7, 2014 | Approved | |
SEEK DSC Networking 1.0.0.72 | 414 | Thursday, November 6, 2014 | Approved | |
SEEK DSC Networking 1.0.0.71 | 402 | Thursday, November 6, 2014 | Approved | |
SEEK DSC Networking 1.0.0.70 | 422 | Thursday, November 6, 2014 | Approved | |
SEEK DSC Networking 1.0.0.69 | 448 | Monday, November 3, 2014 | Approved | |
SEEK DSC Networking 1.0.0.68 | 424 | Monday, November 3, 2014 | Approved | |
SEEK DSC Networking 1.0.0.67 | 388 | Monday, November 3, 2014 | Approved | |
SEEK DSC Networking 1.0.0.64 | 423 | Thursday, October 30, 2014 | Approved | |
SEEK DSC Networking 1.0.0.63 | 409 | Thursday, October 30, 2014 | Approved | |
SEEK DSC Networking 1.0.0.62 | 431 | Monday, October 27, 2014 | Approved | |
SEEK DSC Networking 1.0.0.61 | 445 | Friday, October 24, 2014 | Approved | |
SEEK DSC Networking 1.0.0.60 | 396 | Friday, October 24, 2014 | Approved | |
SEEK DSC Networking 1.0.0.59 | 398 | Friday, October 24, 2014 | Approved | |
SEEK DSC Networking 1.0.0.58 | 436 | Friday, October 24, 2014 | Approved | |
SEEK DSC Networking 1.0.0.55 | 458 | Friday, October 24, 2014 | Approved | |
SEEK DSC Networking 1.0.0.54 | 471 | Wednesday, October 15, 2014 | Approved | |
SEEK DSC Networking 1.0.0.53 | 448 | Wednesday, October 15, 2014 | Approved | |
SEEK DSC Networking 1.0.0.52 | 401 | Wednesday, October 15, 2014 | Approved | |
SEEK DSC Networking 1.0.0.51 | 416 | Wednesday, October 15, 2014 | Approved | |
SEEK DSC Networking 1.0.0.50 | 433 | Sunday, October 12, 2014 | Approved | |
SEEK DSC Networking 1.0.0.48 | 423 | Friday, October 10, 2014 | Approved | |
SEEK DSC Networking 1.0.0.47 | 389 | Friday, October 10, 2014 | Approved | |
SEEK DSC Networking 1.0.0.46 | 422 | Friday, October 10, 2014 | Approved | |
SEEK DSC Networking 1.0.0.45 | 413 | Thursday, October 9, 2014 | Approved | |
SEEK DSC Networking 1.0.0.43 | 407 | Wednesday, October 8, 2014 | Approved | |
SEEK DSC Networking 1.0.0.42 | 346 | Wednesday, October 8, 2014 | Approved | |
SEEK DSC Networking 1.0.0.41 | 371 | Thursday, October 2, 2014 | Approved | |
SEEK DSC Networking 1.0.0.40 | 419 | Thursday, September 25, 2014 | Approved | |
SEEK DSC Networking 1.0.0.39 | 409 | Thursday, September 25, 2014 | Approved | |
SEEK DSC Networking 1.0.0.37 | 374 | Wednesday, September 24, 2014 | Approved | |
SEEK DSC Networking 1.0.0.36 | 387 | Monday, September 22, 2014 | Approved | |
SEEK DSC Networking 1.0.0.35 | 399 | Monday, September 15, 2014 | Approved | |
SEEK DSC Networking 1.0.0.34 | 397 | Monday, September 15, 2014 | Approved | |
SEEK DSC Networking 1.0.0.33 | 335 | Monday, September 15, 2014 | Approved | |
SEEK DSC Networking 1.0.0.32 | 420 | Thursday, September 11, 2014 | Approved | |
SEEK DSC Networking 1.0.0.31 | 335 | Wednesday, September 10, 2014 | Approved | |
SEEK DSC Networking 1.0.0.30 | 390 | Wednesday, September 10, 2014 | Approved | |
SEEK DSC Networking 1.0.0.29 | 363 | Wednesday, September 10, 2014 | Approved | |
SEEK DSC Networking 1.0.0.28 | 383 | Tuesday, September 9, 2014 | Approved | |
SEEK DSC Networking 1.0.0.27 | 403 | Tuesday, September 9, 2014 | Approved | |
SEEK DSC Networking 1.0.0.20 | 367 | Tuesday, September 9, 2014 | Approved | |
SEEK DSC Networking 1.0.0.19 | 423 | Tuesday, September 9, 2014 | Approved | |
SEEK DSC Networking 1.0.0.18 | 404 | Tuesday, September 9, 2014 | Approved | |
SEEK DSC Networking 1.0.0.17 | 404 | Tuesday, September 9, 2014 | Approved | |
SEEK DSC Networking 1.0.0.13 | 401 | Friday, September 5, 2014 | Approved | |
SEEK DSC Networking 1.0.0.11 | 382 | Friday, September 5, 2014 | Approved | |
SEEK DSC Networking 1.0.0 | 419 | Tuesday, September 9, 2014 | Approved | |
SEEK DSC Networking 0.0.0.1 | 371 | Tuesday, May 5, 2015 | Approved |
© 2015 SEEK Ltd. All rights reserved.
This package has no dependencies.
Ground Rules:
- This discussion is only about SEEK DSC Networking and the SEEK DSC Networking package. If you have feedback for Chocolatey, please contact the Google Group.
- This discussion will carry over multiple versions. If you have a comment about a particular version, please note that in your comments.
- The maintainers of this Chocolatey Package will be notified about new comments that are posted to this Disqus thread, however, it is NOT a guarantee that you will get a response. If you do not hear back from the maintainers after posting a message below, please follow up by using the link on the left side of this page or follow this link to contact maintainers. If you still hear nothing back, please follow the package triage process.
- Tell us what you love about the package or SEEK DSC Networking, or tell us what needs improvement.
- Share your experiences with the package, or extra configuration or gotchas that you've found.
- If you use a url, the comment will be flagged for moderation until you've been whitelisted. Disqus moderated comments are approved on a weekly schedule if not sooner. It could take between 1-5 days for your comment to show up.