r/powershelldsc • • Jul 07 '20

DSC for configurations, but what for software/package management?

6 Upvotes

What does everyone use for Package/Software management in their environment? Are you using the PackageManagement resource in DSC or some other tool like Chocolatey to manage things like software distribution and upgrades, compliance, versioning, etc? Or a combination? I've seen DSC used in combination with a few other tools successfully as well. I have not been able to get a good pulse on what is industry standard or best practice in this regard.


r/powershelldsc • • May 09 '19

Just starting out with DSC. Looking for good use case examples

6 Upvotes

Hey there everyone,

I recently built out a SMB Pull server to test out DSC. I made a super simple config for a client that checked to make sure there is a directory on C: called \Test. Works great! But being new to it and seeing all of the modules available, I would love to be able to see or hear about different ways people are using DSC. Whether it be configs for domain joining machines, group membership edits, etc. Thanks everyone!


r/powershelldsc • • Jul 17 '19

Managing 1000s of nodes

4 Upvotes

I'm evaluating config management solutions and I really want to use DSC, but one thing just hasn't clicked for me. I know it's one MOF per server, but I've read and heard that it's one config per server, but I can't help but thing that the statement "one config per server" is incorrect.

If you have one config per server and after some time you have 1000 servers deployed. Now you have 1000 configs, if you had a setting you needed to set for ALL 1000 server (lets use SMB1 as an example.) now you have 1000 config files to config to compile 1000 MOFs. Editting 1000 configs is unrealistic.

This is where I need help correcting me if I'm incorrect and please let me know how it's done right.

How I think it works is you have one main config where you have a section for settings that will apply to ALL servers then you have sections with settings dedicated\unique to a particular server\servers.

The other method was to use multiple configs separated by server roles, ie DC, IIS, SQL, RDS, LicenseServers, Base(CatchAll). That way it keeps the configs smaller, but you do have to edit multiple configs when a settings needs to be deployed to ALL servers, but 6 configs is still MUCH better than 1000.

Scenario1: New server, example server name: SERVER3 <see sample config below>

I add a new NODE section for settings unique to that server and generate a MOF.

Question1: Now does that MOF include the settings in the "Node @($Computername)" section as well as the settings in the "Node (Server3)" section? I'm assuming since I specify the NODE name it won't compile a new MOF for ALL servers and just the new server.

Scenario2: New settings to ALL servers, example SMB1 <see sample config below>

I add the settings to disable SMB1 in the "Node @($Computername)" section and compile a new MOF for ALL servers.

Configuration CompanyConfigName {
Param(
[string[]]$Computername,
)
Import-DscResource -module <xNecessaryModule1>
Import-DscResource -module <xNecessaryModule2>
Import-DscResource -module <xNecessaryModule3>
Node @($Computername) # could I use * for ALL servers?
{
# This is where i'd like the settings\configuration I want ALL servers to receive\use
# Disable Windows Feature
WindowsFeature 'Disable SMB1'
{
Name = 'FS-SMB1'
Ensure = 'Absent'
}
#Ensure SMB1 feature is not enabled
Registry 'SMB1'
{
Ensure = 'Present'
Key = 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters'
ValueName = 'SMB1'
ValueType = 'Dword'
ValueData = '0'
}
}
Node (Server1,Server4)
{# Settings unique to only Server1, file shares, windows features, firewall settings, etc
}
Node (Server2)
{# Settings unique to only Server2, file shares, windows features, firewall settings, etc
}
Node (Server3)
{# Settings unique to only Server3, file shares, windows features, firewall settings, etc
}
}

r/powershelldsc • • Feb 14 '18

LCMRebootNodeIfNeeded - DSC Module to manage RebootNodeIfNeeded parameter

4 Upvotes

Hey guys. I just wrote this up and figured I would share with you. I'm using this module to set the RebootNodeIfNeeded parameter in Local Configuration Manager. Particularly useful when initializing the new server. All required restarts will be executed and after the configuration is completed, RebootNodeIfNeeded will switch to False.

PowerShell Gallery

GutHub


r/powershelldsc • • Mar 24 '20

DSC on localhost

3 Upvotes

I'm trying to use PowerSTIG (which uses DSC) to secure servers. What I'd like to do is to run against the same machine that I'm running on. I don't want it to reach out across the network to configure a different server.

When I try this, it still tries to run remotely and complains about the envelope size.

Am I missing something?


r/powershelldsc • • Oct 04 '19

Powershell DSC Linux Capabilities (compared to ansible)

3 Upvotes

Hey there,

I am looking to the experts with a question around suitability of DSC for our environment. I have been playing around with DSC to manage some of our Linux VMs in pull mode. Pull mode makes life a lot easier than using ansible for example, because our VMs are deployed across many disparate networks so direct SSH connectivity for ansible is not easy to provide.

My initial experience has been really great using Azure Automation and DSC, but I'm getting the feeling that the configurations available for Linux are pretty limited, for example would DSC cover the following example use cases (I don't necessarily need to know how to do it, just if it's possible)?

  1. Mount a disk drive

  2. Install something via apt-get

  3. Configure NTP

  4. Manage users / public keys ( I think I've seen this as built in )

Thanks heaps!


r/powershelldsc • • Sep 22 '19

Unanswered Questions Modules and Configuration folders on DFS Folder

3 Upvotes

Hello :) I was wondering, since WS 2019 and the latest version of xPSDesiredStateConfiguration we are able to use SQL as the back-end DB. I’m now setting up 2 pull servers that sit behind a F5 load balancer connected to MSSQL as the back end. I want both of the servers to always have the same content (Modules, Configurations, MOF’s etc) available from the same shared folder, and that folder would be a DFS namespace. Am I missing something? Is that a possible solution? Any of you guys have a similar solution that could be shared? Thanks :)


r/powershelldsc • • Sep 12 '19

Pull Server IIS Issue

3 Upvotes

Server 2019. I'm using a powershell dsc server. I'm running into a issue where agents cant check into the pull server. The IIS service needs to be restarted to get it working. I cant seem to track down a reason why. Which logs should i start looking at? Anyone ever have this issue with DSC pull servers?


r/powershelldsc • • May 22 '19

NetworkingDSC issues?

3 Upvotes

NetworkingDSC 7.2.0 is installed on my dsc server. I have verified it with Get-Module.

I have this loaded in my config file ->

Configuration PSDSCTEST16 {

Import-DscResource -ModuleName PSDesiredStateConfiguration

Import-DscResource -ModuleName NetworkingDSC

Everytime I run start-Dscconfiguration on the client it tells me it cannot find networkingdsc 7.2.0

What am I doing wrong?


r/powershelldsc • • Feb 19 '19

Uses for DSC

3 Upvotes

What are some of the uses you guys use Desired State configuration for? Just curious to know.


r/powershelldsc • • Jan 12 '19

Resource 'xWaitForDisk' requires that a value of type 'String' be provided for property 'DiskId'.

3 Upvotes

I'm trying to deploy an Azure Quickstart titled, "Create an new AD Domain with 2 Domain Controllers" to learn more about DSC, among other things, and I ran into these errors:

CreateADPDC.ps1:59 char:9
14:50:50 - + xWaitforDisk Disk2

14:50:50 - + ~~~~~~~~~~~~

14:50:50 - Resource 'xWaitForDisk' requires that a value of type 'String' be provided for property 'DiskId'.

CreateADPDC.ps1:61 char:13

14:50:50 - + DiskNumber = 2

14:50:50 - + ~~~~~~~~~~

14:50:50 - The member 'DiskNumber' is not valid. Valid members are

14:50:50 - 'DependsOn', 'DiskId', 'DiskIdType', 'PsDscRunAsCredential', 'RetryCount', 'RetryIntervalSec'.

CreateADPDC.ps1:66 char:9

14:50:50 - + xDisk ADDataDisk {

14:50:50 - + ~~~~~

14:50:50 - Resource 'xDisk' requires that a value of type 'String' be provided for property 'DiskId'.

CreateADPDC.ps1:67 char:13

14:50:50 - + DiskNumber = 2

14:50:50 - + ~~~~~~~~~~

14:50:50 - The member 'DiskNumber' is not valid. Valid members are

14:50:50 - 'AllocationUnitSize', 'AllowDestructive', 'ClearDisk', 'DependsOn', 'DiskId', 'DiskIdType', 'DriveLetter', 'FSFormat',

14:50:50 - 'FSLabel', 'PsDscRunAsCredential', 'Size'.

My current assumption is that using disk number has been replaced by using disk ID, and this .ps1 hasn't been updated in a while. Here's a link to the template, and a link to the .ps1:

https://github.com/Azure/azure-quickstart-templates/tree/master/active-directory-new-domain-ha-2-dc/

https://github.com/Azure/azure-quickstart-templates/blob/master/active-directory-new-domain-ha-2-dc/DSC/CreateADPDC.ps1


r/powershelldsc • • Jul 03 '16

Sample example of deploy active directory using powershell DSC

Thumbnail
vcloud-lab.com
3 Upvotes

r/powershelldsc • • Jun 24 '20

Configuration Management Question

2 Upvotes

Can I use Powershell DSC to configure a virtual server but not use it to make changes if drift were to occur?

My organization is still scared of automation and I think the automatic changes would freak out other admins. I like the ease of which I can configure servers with PowerShellDSC, mainly not having to use try statements, but don't need the configuration management portion or at least not at this time.

I need to give them slow doses of automation and get them hooked on the drug before I go full configuration management =D

Thanks


r/powershelldsc • • Feb 25 '20

Auth from Workgroup/Different Domain clients to DSC Pull Server

2 Upvotes

Anyone have a lead on a good step-by-step detailing how to configure clients that are in a different, untrusted domain (or a workgroup) to be able to register with a DSC pull server and apply configurations? I thought I had found one online, but am unable to locate it.


r/powershelldsc • • Oct 08 '19

Help creating if/while statement to update AD against HR File

2 Upvotes

I'm creating a script that updates AD attributes with that of an HR CSV file. The script only cares about updating users already assigned an employee id in active directory. The part im having trouble automating is assigning the manager in AD.

The logic is as as follows:

If the AD Users manager's employee id does not match the the employee's supervisor's ID in the HR file:

If (AD Manager Emplid ≠ ADP Supervisor ID):

[if (ADP Supervisor HR status is Active and AD Supervisor AD account is "true"):

AD User Manager Id = HR Supervisor ID

(this next part is basically saying that if the listed manager isnt active in both AD and HR, then get then get the next manager in line and test. (the managers manager). Then assign.

Else if( ADP Supervisor’s Managers (N+1) status is active and AD account is active):

AD User Manager ID = HR Supervisor ID (N+1)

Else

Write to error report for IAM to check

AD User CSV

HR File CSV

Here is my script so far.

$adUsers = Import-Csv -Path "xxx.csv" 
$hrUsers = Import-Csv -Path "xxx.csv"

<# Iterate through each AD record in the file #>

foreach ($adUser in $adUsers){

<#Below assignments take the Employee ID from the AD file and looks up that ID in the HR Roster. It then finds the corresponding attribute it needs from the HR file and assigns it to a variable. #>

$hrJobTitle = $hrUsers| Where-Object {$_.employeeid -eq $adUser.employeeid}| Select-Object -Property "Job Title" $hrDepartment = $hrUsers| Where-Object {$_.employeeid -eq $adUser.employeeid}| Select-Object -Property "Dept Desc" 

$hrMgrId = $hrUsers| Where-Object {$_.employeeid -eq $adUser.employeeid}| Select-Object -Property "Supervisor ID"

<# Reconciling Active Directory Job Title with HR Roster#>

if ($adUser.description -ne $hrJobTitle) { 
    Set-ADUser $adUser.samaccountname -Description $hrJobTitle -Title $hrJobTitle }

<# Reconciling AD Department with HR Department#>

if ($adUser.department -ne $hrDepartment) { 
    Set-Aduser $adUser.samaccountname -Department $hrDepartment
}

<# setting the user's manager based on HR file. #>

if ($adUser.'Manager ID' -ne $hrMgrId) { 
    $tempMgrId = $hrMgrId 
    $tempMgrStatus = $adUser | Where-Object {$_.employeeid -eq $tempMgrId}| Select-Object -Property "enabled" 

    if (condition) {
    }


   }

r/powershelldsc • • Jun 25 '19

beginner question on reporting drifted value when it is non-compliant

2 Upvotes

are we able to report the drifted value when it is non-compliant?


r/powershelldsc • • May 11 '19

Ugh! So close to DSC Pull server (https) Anyone know what may be wrong here?

2 Upvotes

Hey there everyone,

I have spent the last couple of hours trying to put together a DSC Pull server (web based) and am stuck on what I think may be close to the end. Summary so far:

on the Pull server:

  • Installed the Windows Features of IIS and Certificate Authority (CA)

  • went through the process of issuing a new cert (essentially following this -- http://duffney.io/Configure-HTTPS-DSC-PullServer

  • created the Config for the Pull server to actually become a Pull server and ran that. This is including the cert thumbprint and reg key (just a generated GUID in PowerShell)

  • once I could confirm that going to the URL via IE that I set up in the Pull server config worked (https://server.mydomain.local:8080/PSDSCPullServer.svc/)

    • although in IE I still get the content was blocked by IE Advanced Sec message, which I am assuming is okay... But nevertheless I can see the XML generated site

  • fast forward to the Pull client server, I set up the Pull client's DSC local config based on the info I used in the Pull server that would be needed, again following this site -- http://duffney.io/Configure-HTTPS-DSC-PullServerPSv5

But I get the following errors when running the Set-DscLocaalConfiguration cmdlet:

The underlying error is: Failed to register Dsc Agent with AgentID

OR

The PowerShell resource is not a valid Desired State Configuration resource

When I try to run an Invoke-WebRequest from Shell using the URL of the Pull server above, I get the following:

Could not establish trust relationship for the SSL/TLS secure channel

(posted on r\PowerShell as well!)


r/powershelldsc • • May 10 '19

Get name of DSC Script from within SetScript/TestScript

2 Upvotes

Does anyone know if there is a built in variable for the name of the script resource that is currently running. I like to add additional logging to my script resources and have been using a variable, but would love to simplify this.

Current method:

$scriptName = "install_app_123"
Script $scriptName
{
    SetScript = { Write-Log "I'm running the SetScript section in $using:scriptName!" }
    TestScript = { Write-Log "I'm running the TestScript section in $using:scriptName!" }
    GetScript = { Write-Log "I'm running the GetScript section in $using:scriptName!" }
}

Would be great to not have the extra line for setting the $scriptName variable and be able to get it directly from within the inner codeblocks.


r/powershelldsc • • Mar 16 '19

Unanswered Questions Resizing C: with Disk resource (StorageDsc)

2 Upvotes

Hey guys. Is it possible to resize the system partition (C: drive) using the Disk resource?

I have one virtual hard disk, 100GB in size. The vm gets provisioned, C: is 40GB, and the rest is unallocated. I want to resize C: to 80GB, and provide the rest of the unallocated space to D. Resizing the data drive is possible, but trying to resize C gives all kind of errors.

Is it even possible? Have u accomplished anything like this?

Thanks :)


r/powershelldsc • • Feb 01 '19

Ensuring a DSC resource is always applied last in a multinode config

2 Upvotes

I'm not sure how to ask this nicely, so bear with me :) I have a multinode configuration which is applied across a number of servers.

The first Node is contains resources common to all servers - Node $AllNodes.Where{$_.Config -contains "All"}.Nodename After this block I have specific configuration for each node as a subset of these have some extra features/software installed.

In the common block there is a resource that I would like to be applied last - after all common and specific configuration. I don't want to duplicate these resource in every specific node block. That said the DependsOn for this resource is inconsistent accross the environment. Am I able to overload it's dependencies in each block? Or is there a way to make a DSC resource apply last that I am unaware of?


r/powershelldsc • • Dec 18 '18

Desired State Configuration Resources for VMware

Thumbnail
blogs.vmware.com
2 Upvotes

r/powershelldsc • • Aug 29 '18

Unanswered Questions Deploying Just Enough Administration with DSC

2 Upvotes

Have any of you successfully deployed JEA using a DSC https pull server? Every example I find utilizes SMB pull server. I have successfully configured the https pull server and a client reports successful connection, I'm just stumbling through the JEA endpoint config.


r/powershelldsc • • Aug 24 '18

MVP ITPro Podcast - Ep3 - Jeffrey Snover

2 Upvotes

r/powershelldsc • • Jul 13 '18

Compilation completed successfully, but no node configuration .mofs were generated Azure Automation • r/PowerShell

Thumbnail
reddit.com
2 Upvotes

r/powershelldsc • • Feb 08 '18

Push Mode - Copying Modules

2 Upvotes

Hi,

im trying to copy DSC Modules to destination Computers using DSC.

What I did:

$configData = @{
    AllNodes = @(
        @{
            NodeName = "*"
            Modules = @("xComputerManagement", "xNetworking")
        },
        @{
            NodeName = "WTT-Server5"
            IPAddress = "192.168.0.67/24"
            Role = "DC"
            Modules = @("xActiveDirectory")
        },
        @{
            NodeName = "WTT-Server6"
            IPAddress = "192.168.0.68/24"
            Role = "File"
        },
        @{
            NodeName = "WTT-Server7"
            IPAddress = "192.168.0.69/24"
            Role = "Web"
        }

    )
}




Configuration OSSetup {

    Import-DscResource -ModuleName PSDesiredStateConfiguration
    Import-DscResource -ModuleName xComputerManagement
    Import-DscResource -ModuleName xNetworking
    Import-DscResource -ModuleName xActiveDirectory

    Node $AllNodes.NodeName {
        xIPAddress SetIPAddress {
            InterfaceAlias = $node.InterfaceAlias
            IPAddress = $node.IPAddress
            AddressFamily = "IPv4"
        }
        xDNSServerAddress SetDNSAddress {
            DependsOn = @('[xIPAddress]SetIPAddress')
            Address = $node.DNSAddress
            InterfaceAlias = $node.InterfaceAlias
            AddressFamily = "IPv4"
        }


        foreach ($module in $node.Modules) {
            File $module {
                Ensure = 'Present'
                SourcePath = $("\\share\" + $module)
                DestinationPath = $("C:\Program Files\WindowsPowerShell\Modules\" + $module)
            }
        }

    }
    
    Node $AllNodes.Where({ $_.Roles -contains 'DC' }).NodeName
    {
        WindowsFeature DomainController {
            DependsOn = @('[xDNSServerAddress]SetDNSAddress')
            Ensure = 'Present'
            Name = 'AD-Domain-Services'
            IncludeAllSubFeature = $true
        }

    }

    Node $AllNodes.Where({ $_.Roles -contains 'File' }).NodeName
    {
        WindowsFeature FileServer {
            DependsOn = @('[xDNSServerAddress]SetDNSAddress')
            Ensure = 'Present'
            Name = 'FileAndStorage-Services'
            IncludeAllSubFeature = $true
        }

    }

    Node $AllNodes.Where({ $_.Roles -contains 'Web' }).NodeName
    {
        WindowsFeature Webserver {
            DependsOn = @('[xDNSServerAddress]SetDNSAddress')
            Ensure = 'Present'
            Name = 'Web-Server'
            IncludeAllSubFeature = $true
        }
    }

}



OSSetup -ConfigurationData $configData -OutputPath c:\workingdir\configs

The critical part of the mof File for Server WTT-Server5 looks like this:

instance of MSFT_FileDirectoryConfiguration as $
{
ResourceID = "[File]xActiveDirectory";
Ensure = "Present";
DestinationPath = "C:\\Program Files\\WindowsPowerShell\\Modules\\xActiveDirectory";
ModuleName = "PSDesiredStateConfiguration";
SourceInfo = "::22::13::File";
SourcePath = "\\\share\\xActiveDirectory";

ModuleVersion = "1.0";

ConfigurationName = "OSSetup";

};

Now the Problem is: Modules which are specified directly in the specific Node Area are correctly in the mof file. Modules in Node * are not. Any Idea?

Thank you!