### Install Project Dependencies Source: https://github.com/dsccommunity/computermanagementdsc/wiki/Running-Gulp-based-tests Downloads and installs all the necessary Node.js dependencies for the project, including Gulp plugins, as defined in the package.json file. Run this after installing Gulp globally. ```bash npm install ``` -------------------------------- ### Install ComputerManagementDsc Module Source: https://github.com/dsccommunity/computermanagementdsc/wiki/Home Use PowerShellGet to download and install the module from the PSGallery repository. ```powershell Find-Module -Name ComputerManagementDsc -Repository PSGallery | Install-Module ``` -------------------------------- ### Install Gulp Globally Source: https://github.com/dsccommunity/computermanagementdsc/wiki/Running-Gulp-based-tests Installs the Gulp command-line tool globally on your system. This is a prerequisite for running Gulp tasks. ```bash npm install gulp --global ``` -------------------------------- ### Add Windows Capability with Logging and Source Source: https://github.com/dsccommunity/computermanagementdsc/wiki/WindowsCapability Installs a capability using a custom source path, log level, and log file path. ```powershell Configuration WindowsCapability_AddWindowsCapabilitywithLogLevelLogPathandSource_Config { Import-DSCResource -ModuleName ComputerManagementDsc Node localhost { WindowsCapability OpenSSHClient { Name = 'OpenSSH.Client~~~~0.0.1.0' Ensure = 'Present' LogLevel = 'Errors' LogPath = 'C:\Temp\Logfile.log' Source = 'F:\Source\FOD\LanguagesAndOptionalFeatures' } } } ``` -------------------------------- ### Add Windows Capability with Logging Source: https://github.com/dsccommunity/computermanagementdsc/wiki/WindowsCapability Installs a capability while specifying custom log levels and a specific log file path. ```powershell Configuration WindowsCapability_AddWindowsCapabilitywithLogLevelandLogPath_Config { Import-DSCResource -ModuleName ComputerManagementDsc Node localhost { WindowsCapability OpenSSHClient { Name = 'OpenSSH.Client~~~~0.0.1.0' Ensure = 'Present' LogLevel = 'Errors' LogPath = 'C:\Temp\Logfile.log' } } } ``` -------------------------------- ### Create SMB Share with Default Settings Source: https://github.com/dsccommunity/computermanagementdsc/wiki/SmbShare This example demonstrates creating an SMB share named 'Temp' for the path 'C:\Temp' using the default values provided by the `New-SmbShare` cmdlet. Ensure the ComputerManagementDsc module is imported. ```powershell Configuration SmbShare_CreateShare_Config { Import-DscResource -ModuleName ComputerManagementDsc Node localhost { SmbShare 'TempShare' { Name = 'Temp' Path = 'C:\Temp' } } } ``` -------------------------------- ### Add Windows Capability Source: https://github.com/dsccommunity/computermanagementdsc/wiki/WindowsCapability Configures the system to ensure the XPS Viewer capability is installed. ```powershell Configuration WindowsCapability_AddWindowsCapability_Config { Import-DSCResource -ModuleName ComputerManagementDsc Node localhost { WindowsCapability XPSViewer { Name = 'XPS.Viewer~~~~0.0.1.0' Ensure = 'Present' } } } ``` -------------------------------- ### Verify ComputerManagementDsc Installation Source: https://github.com/dsccommunity/computermanagementdsc/wiki/Home Confirm that the module is correctly installed by listing the available DSC resources. ```powershell Get-DscResource -Module ComputerManagementDsc ``` -------------------------------- ### Create Scheduled Task at Startup Source: https://github.com/dsccommunity/computermanagementdsc/wiki/ScheduledTask Creates a scheduled task that runs at system startup, repeating at a specified interval for a defined duration. The task is configured to start a PowerShell process. ```powershell Configuration ScheduledTask_CreateScheduledTasksAtStartup_Config { Import-DscResource -ModuleName ComputerManagementDsc Node localhost { ScheduledTask ScheduledTaskStartupAdd { TaskName = 'Test task Startup' TaskPath = '\MyTasks' ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' ScheduleType = 'AtStartup' RepeatInterval = '00:15:00' RepetitionDuration = '08:00:00' Delay = '00:15:00' } } } ``` -------------------------------- ### Configure System Locale via DSC Source: https://github.com/dsccommunity/computermanagementdsc/wiki/SystemLocale Example configuration to set the system locale to 'ja-JP' on the target node. ```powershell Configuration SystemLocale_SetSystemLocale_Config { param ( [Parameter()] [System.String[]] $NodeName = 'localhost' ) Import-DSCResource -ModuleName ComputerManagementDsc Node $NodeName { SystemLocale SystemLocaleExample { IsSingleInstance = 'Yes' SystemLocale = 'ja-JP' } } } ``` -------------------------------- ### DisallowDemandStart Source: https://github.com/dsccommunity/computermanagementdsc/wiki/ScheduledTask Prevents the task from being started on demand. Defaults to false. ```APIDOC ## DisallowDemandStart ### Description Indicates whether the task is prohibited to run on demand or not. ### Parameter Type Write ### Data Type Boolean ### Default Value $false ``` -------------------------------- ### AllowStartIfOnBatteries Source: https://github.com/dsccommunity/computermanagementdsc/wiki/ScheduledTask Determines if the task can start when the system is running on battery power. Defaults to false. ```APIDOC ## AllowStartIfOnBatteries ### Description Indicates whether the task should start if the machine is on batteries or not. ### Parameter Type Write ### Data Type Boolean ### Default Value $false ``` -------------------------------- ### Configure Multiple PowerShell Execution Policies Source: https://github.com/dsccommunity/computermanagementdsc/wiki/PowerShellExecutionPolicy This example demonstrates setting PowerShell execution policies for both the current user and the local machine. The ComputerManagementDsc module must be imported. ```powershell Configuration PowerShellExecutionPolicy_SetPolicyForMultipleScopes_Config { Import-DscResource -ModuleName ComputerManagementDsc Node localhost { PowerShellExecutionPolicy ExecutionPolicyCurrentUser { ExecutionPolicyScope = 'CurrentUser' ExecutionPolicy = 'RemoteSigned' } # End of ExecutionPolicyCurrentUser Resource PowerShellExecutionPolicy ExecutionPolicyLocalMachine { ExecutionPolicyScope = 'LocalMachine' ExecutionPolicy = 'RemoteSigned' } # End of ExecutionPolicyLocalMachine Resource } # End of Node } # End of Configuration ``` -------------------------------- ### Configure Pending Reboot after Domain Join Source: https://github.com/dsccommunity/computermanagementdsc/wiki/PendingReboot This example configures the PendingReboot resource to allow the LCM node to reboot after a domain join operation. Ensure the LCM is configured with `RebootNodeIfNeeded` set to $true. ```powershell Configuration PendingReboot_RebootAfterDomainJoin_Config { param ( [Parameter(Mandatory = $true)] [ValidateNotNullorEmpty()] [System.Management.Automation.PSCredential] $Credential ) Import-DscResource -ModuleName ComputerManagementDsc Node localhost { Computer JoinDomain { Name = 'Server01' DomainName = 'Contoso' Credential = $Credential # Credential to join to domain } PendingReboot RebootAfterDomainJoin { Name = 'DomainJoin' } } } ``` -------------------------------- ### Register PowerShell Repository Source: https://context7.com/dsccommunity/computermanagementdsc/llms.txt Manages PowerShellGet repository registrations for installing modules and scripts. ```powershell #Requires -module ComputerManagementDsc Configuration Register_PSRepository_Present { Import-DscResource -ModuleName ComputerManagementDsc Node localhost { PSResourceRepository 'Register MyPSRepository' { Name = 'MyPSRepository' SourceLocation = 'https://www.mypsrepository.com/api/v2' ScriptSourceLocation = 'https://www.mypsrepository.com/api/v2/package/' PublishLocation = 'https://www.mypsrepository.com/api/v2/items/psscript' ScriptPublishLocation = 'https://www.mypsrepository.com/api/v2/package/' InstallationPolicy = 'Trusted' PackageManagementProvider = 'NuGet' } } } ``` -------------------------------- ### Example of Invalid SMB Share Access Permissions Configuration Source: https://github.com/dsccommunity/computermanagementdsc/blob/main/source/DSCResources/DSC_SmbShare/README.md This configuration will throw an exception because empty collections are provided for access permissions. Ensure at least one member is added to an access permission parameter or remove all parameters to manage permissions manually. ```powershell SmbShare 'Integration_Test' { Name = 'TestShare' Path = 'C:\\Temp' FullAccess = @() ChangeAccess = @() ReadAccess = @() NoAccess = @() } ``` -------------------------------- ### Create an AtLogon Scheduled Task with Delay and Stop at Duration End Source: https://github.com/dsccommunity/computermanagementdsc/wiki/ScheduledTask This configuration creates a scheduled task that triggers upon user logon, with a specified start time, repetition, and an option to stop the task at the end of its repetition duration. A delay can also be applied to the initial trigger. Requires the 'ComputerManagementDsc' module. ```powershell Configuration ScheduledTask_CreateScheduledTasksAtLogon_Config { Import-DscResource -ModuleName ComputerManagementDsc Node localhost { ScheduledTask ScheduledTaskLogonAdd { TaskName = 'Test task Logon' TaskPath = '\MyTasks' ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' ScheduleType = 'AtLogon' StartTime = '2018-10-01T01:00:00' RepeatInterval = '00:15:00' RepetitionDuration = '08:00:00' StopAtDurationEnd = $true User = 'Domain\UserName' Delay = '00:15:00' } } } ``` -------------------------------- ### Configure Pending Reboot to Skip Specific Triggers Source: https://github.com/dsccommunity/computermanagementdsc/wiki/PendingReboot This example configures the PendingReboot resource to only allow reboots triggered by the ConfigMgr client, skipping all other specified reboot triggers. This is useful when you want to control reboots based on specific system states. ```powershell Configuration PendingReboot_ConfigMgrReboot_Config { Import-DscResource -ModuleName ComputerManagementDsc Node localhost { TimeZone TimeZoneExample { IsSingleInstance = 'Yes' TimeZone = 'Tonga Standard Time' } PendingReboot ConfigMgrReboot { Name = 'ConfigMgr' SkipComponentBasedServicing = $true SkipWindowsUpdate = $true SkipPendingFileRename = $true SkipPendingComputerRename = $true SkipCcmClientSDK = $false } } } ``` -------------------------------- ### Add Custom PSRepository Source: https://github.com/dsccommunity/computermanagementdsc/wiki/PSResourceRepository This configuration adds a custom PSRepository with specified source, script source, publish, script publish locations, installation policy, and package management provider. Ensure the repository is present. ```powershell configuration Register_PSRepository_Present { Import-DscResource -ModuleName 'ComputerManagementDsc' node localhost { PSResourceRepository 'Register MyPSRepository PSRepository' { Name = 'MyPSRepository' SourceLocation = 'https://www.mypsrepository.com/api/v2' ScriptSourceLocation = 'https://www.mypsrepository.com/api/v2/package/' PublishLocation = 'https://www.mypsrepository.com/api/v2/items/psscript' ScriptPublishLocation = 'https://www.mypsrepository.com/api/v2/package/' InstallationPolicy = 'Trusted' PackageManagementProvider = 'NuGet' } } } ``` -------------------------------- ### Create an SMB share with all properties Source: https://github.com/dsccommunity/computermanagementdsc/wiki/SmbShare Configures an SMB share with specific access permissions and settings. Unsupported properties default to New-SmbShare cmdlet defaults. ```powershell Configuration SmbShare_CreateShareAllProperties_Config { Import-DscResource -ModuleName ComputerManagementDsc Node localhost { SmbShare 'TempShare' { Name = 'Temp' Path = 'C:\Temp' Description = 'Some description' ConcurrentUserLimit = 20 EncryptData = $false FolderEnumerationMode = 'AccessBased' CachingMode = 'Manual' ContinuouslyAvailable = $false FullAccess = @() ChangeAccess = @('AdminUser1') ReadAccess = @('Everyone') NoAccess = @('DeniedUser1') } } } ``` -------------------------------- ### IdleDuration Source: https://github.com/dsccommunity/computermanagementdsc/wiki/ScheduledTask Specifies the minimum duration the system must be idle before the task can start. ```APIDOC ## IdleDuration ### Description Specifies the amount of time that the computer must be in an idle state before Task Scheduler runs the task. ### Parameter Type Write ### Data Type String ``` -------------------------------- ### Configure all SMB Server properties Source: https://github.com/dsccommunity/computermanagementdsc/wiki/SmbServerConfiguration Sets all supported SMB Server configuration values to a known state on the local node. ```powershell Configuration SmbServerConfiguration_AllProperties_Config { Import-DscResource -ModuleName ComputerManagementDsc Node localhost { SmbServerConfiguration SmbServer { IsSingleInstance = 'Yes' AnnounceComment = 'SMB server hello' AnnounceServer = $true AsynchronousCredits = 64 AuditSmb1Access = $false AutoDisconnectTimeout = 15 AutoShareServer = $true AutoShareWorkstation = $true CachedOpenLimit = 10 DurableHandleV2TimeoutInSeconds = 180 EnableAuthenticateUserSharing = $false EnableDownlevelTimewarp = $false EnableForcedLogoff = $true EnableLeasing = $true EnableMultiChannel = $true EnableOplocks = $true EnableSecuritySignature = $false EnableSMB1Protocol = $false EnableSMB2Protocol = $true EnableStrictNameChecking = $true EncryptData = $false IrpStackSize = 15 KeepAliveTime = 2 MaxChannelPerSession = 32 MaxMpxCount = 50 MaxSessionPerConnection = 16384 MaxThreadsPerQueue = 20 MaxWorkItems = 1 NullSessionPipes = 'NullPipe' NullSessionShares = 'NullShare' OplockBreakWait = 35 PendingClientTimeoutInSeconds = 120 RejectUnencryptedAccess = $true RequireSecuritySignature = $false ServerHidden = $true Smb2CreditsMax = 2048 Smb2CreditsMin = 128 SmbServerNameHardeningLevel = 0 TreatHostAsStableStorage = $false ValidateAliasNotCircular = $true ValidateShareScope = $true ValidateShareScopeNotAliased = $true ValidateTargetName = $true } } } ``` -------------------------------- ### Create SMB Share with All Properties Source: https://context7.com/dsccommunity/computermanagementdsc/llms.txt Manages SMB file shares, configuring name, path, description, access limits, encryption, and access permissions for different user groups. ```powershell #Requires -module ComputerManagementDsc Configuration SmbShare_CreateShareAllProperties_Config { Import-DscResource -ModuleName ComputerManagementDsc Node localhost { SmbShare 'TempShare' { Name = 'Temp' Path = 'C:\Temp' Description = 'Temporary file share' ConcurrentUserLimit = 20 EncryptData = $false FolderEnumerationMode = 'AccessBased' CachingMode = 'Manual' ContinuouslyAvailable = $false FullAccess = @() ChangeAccess = @('AdminUser1') ReadAccess = @('Everyone') NoAccess = @('DeniedUser1') } } } ``` -------------------------------- ### IdleWaitTimeout Source: https://github.com/dsccommunity/computermanagementdsc/wiki/ScheduledTask Sets the maximum time Task Scheduler will wait for an idle condition to be met before starting the task. ```APIDOC ## IdleWaitTimeout ### Description Specifies the amount of time that Task Scheduler waits for an idle condition to occur. ### Parameter Type Write ### Data Type String ``` -------------------------------- ### SmbShare Resource Configuration Source: https://github.com/dsccommunity/computermanagementdsc/wiki/SmbShare This snippet demonstrates how to configure the SmbShare resource to create an SMB share with specified properties. ```APIDOC ## SmbShare Resource ### Description The SmbShare resource is used to manage SMB shares and access permissions to SMB shares. ### Parameters #### Path Parameters - **Name** (String) - Key - Specifies the name of the SMB share. - **Path** (String) - Required - Specifies the path of the SMB share. - **CachingMode** (String) - Write - Specifies the caching mode of the offline files for the SMB share. Allowed Values: `None`, `Manual`, `Programs`, `Documents`, `BranchCache`. - **ChangeAccess** (StringArray[]) - Write - Specifies which accounts will be granted modify permission to access the SMB share. - **ConcurrentUserLimit** (UInt32) - Write - Specifies the maximum number of concurrently connected users that the new SMB share may accommodate. If this parameter is set to zero (0), then the number of users is unlimited. The default value is zero (0). - **ContinuouslyAvailable** (Boolean) - Write - Specifies whether the SMB share should be continuously available. - **Description** (String) - Write - Specifies the description of the SMB share. - **EncryptData** (Boolean) - Write - Indicates that the SMB share is encrypted. - **Ensure** (String) - Write - Specifies if the SMB share should be added or removed. Allowed Values: `Present`, `Absent`. - **FolderEnumerationMode** (String) - Write - Specifies which files and folders in the new SMB share are visible to users. Allowed Values: `AccessBased`, `Unrestricted`. - **Force** (Boolean) - Write - Specifies if the SMB share is allowed to be dropped and recreated (required when the path changes). - **FullAccess** (StringArray[]) - Write - Specifies which accounts are granted full permission to access the SMB share. - **NoAccess** (StringArray[]) - Write - Specifies which accounts are denied access to the SMB share. - **ReadAccess** (StringArray[]) - Write - Specifies which accounts is granted read permission to access the SMB share. - **ScopeName** (String) - Write - Specifies the scope in which the share should be created. - **ShadowCopy** (Boolean) - Read - Specifies if this SMB share is a ShadowCopy. - **ShareState** (String) - Read - Specifies the state of the SMB share. - **ShareType** (String) - Read - Specifies the type of the SMB share. - **Special** (Boolean) - Read - Specifies if this SMB share is a special share. E.g. an admin share, default shares, or IPC$ share. ### Requirements #### Cluster Shares The property `ContinuouslyAvailable` can only be set to `$true` when the SMB share is a cluster share in a failover cluster. SMB Transparent Failover does not support cluster disks with 8.3 name generation enabled. #### Access Permissions It is not allowed to provide empty collections in the configuration for the access permissions parameters. The configuration below will cause an exception to be thrown: ```powershell SmbShare 'Integration_Test' { Name = 'TestShare' Path = 'C:\Temp' FullAccess = @() ChangeAccess = @() ReadAccess = @() NoAccess = @() } ``` The access permission parameters must either be all removed to manage the access permission manually, or add at least one member to one of the access permission parameters. If all the access permission parameters are removed, then by design, the cmdlet New-SmbShare will add the *Everyone* group with read access permission to the SMB share. To prevent that, add a member to either access permission parameters. ### Example #### Example 1: Create an SMB Share This example creates an SMB share named 'Temp' for the path 'C:\Temp', using the default values of the cmdlet `New-SmbShare`. ```powershell Configuration SmbShare_CreateShare_Config { Import-DscResource -ModuleName ComputerManagementDsc Node localhost { SmbShare 'TempShare' { Name = 'Temp' Path = 'C:\Temp' } } } ``` ``` -------------------------------- ### DisallowStartOnRemoteAppSession Source: https://github.com/dsccommunity/computermanagementdsc/wiki/ScheduledTask Prohibits the task from starting if triggered within a Remote Applications Integrated Locally (RAIL) session. ```APIDOC ## DisallowStartOnRemoteAppSession ### Description Indicates that the task does not start if the task is triggered to run in a Remote Applications Integrated Locally (RAIL) session. ### Parameter Type Write ### Data Type Boolean ``` -------------------------------- ### Join Computer to Domain Source: https://context7.com/dsccommunity/computermanagementdsc/llms.txt Configures a computer to join an Active Directory domain. Requires valid credentials for domain join. ```powershell #Requires -module ComputerManagementDsc Configuration Computer_JoinDomain_Config { param ( [Parameter(Mandatory = $true)] [ValidateNotNullorEmpty()] [System.Management.Automation.PSCredential] $Credential ) Import-DscResource -Module ComputerManagementDsc Node localhost { Computer JoinDomain { Name = 'Server01' DomainName = 'Contoso' Credential = $Credential # Credential to join to domain } } } ``` -------------------------------- ### PowerPlan Resource Source: https://github.com/dsccommunity/computermanagementdsc/wiki/PowerPlan This resource allows specifying a power plan to activate on the system. ```APIDOC ## PowerPlan Resource ### Description The resource allows specifying a power plan to activate. ### Parameters #### Path Parameters - **IsSingleInstance** (String) - Required - Specifies the resource is a single instance, the value must be 'Yes'. Allowed Values: `Yes` - **Name** (String) - Required - The name or GUID of the power plan to activate. - **IsActive** (Boolean) - Read - Determines if the power plan is active. ### Request Example ```powershell Configuration PowerPlan_SetPowerPlan_Config { Import-DscResource -ModuleName ComputerManagementDsc Node localhost { PowerPlan SetPlanHighPerformance { IsSingleInstance = 'Yes' Name = 'High performance' } } } ``` ### Response #### Success Response (200) - **IsActive** (Boolean) - Determines if the power plan is active. #### Response Example ```json { "IsActive": true } ``` ``` -------------------------------- ### Add PSGallery PSRepository Source: https://github.com/dsccommunity/computermanagementdsc/wiki/PSResourceRepository Use this snippet to add the default PSGallery repository to a machine. Ensure the repository is present. ```powershell configuration Register_PSGallery_Present { Import-DscResource -ModuleName 'ComputerManagementDsc' node localhost { PSResourceRepository 'Register PSGallery PSRepository' { Name = 'PSGallery' Ensure = 'Present' Default = $true } } } ``` -------------------------------- ### Run PowerShell Task Indefinitely Source: https://github.com/dsccommunity/computermanagementdsc/wiki/ScheduledTask Creates a scheduled task to run a PowerShell script every 15 minutes indefinitely. The task starts immediately, runs as the local system account, and has a 15-minute execution time limit per trigger. ```powershell Configuration ScheduledTask_RunPowerShellTaskEvery15MinutesIndefinitely_Config { Import-DscResource -ModuleName ComputerManagementDsc Node localhost { ScheduledTask MaintenanceScriptExample { TaskName = "Custom maintenance tasks" ActionExecutable = "C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe" ActionArguments = "-File `"C:\scripts\my custom script.ps1`"" ScheduleType = 'Once' RepeatInterval = '00:15:00' RepetitionDuration = 'Indefinitely' TriggerExecutionTimeLimit = '00:15:00' } } } ``` -------------------------------- ### Create a Weekly Scheduled Task with Specific Days and Compatibility Source: https://github.com/dsccommunity/computermanagementdsc/wiki/ScheduledTask Use this configuration to create a weekly scheduled task that runs on specific days of the week, with options for repetition, battery usage, and compatibility settings. Ensure the 'ComputerManagementDsc' module is imported. ```powershell Configuration ScheduledTask_CreateScheduledTasksWeekly_Config { Import-DscResource -ModuleName ComputerManagementDsc Node localhost { ScheduledTask ScheduledTaskWeeklyAdd { TaskName = 'Test task Weekly' TaskPath = '\MyTasks' ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' ScheduleType = 'Weekly' WeeksInterval = 1 DaysOfWeek = 'Monday', 'Wednesday', 'Saturday' RepeatInterval = '00:15:00' RepetitionDuration = '08:00:00' AllowStartIfOnBatteries = $true Compatibility = 'Win8' Hidden = $true } } } ``` -------------------------------- ### Compatibility Source: https://github.com/dsccommunity/computermanagementdsc/wiki/ScheduledTask Sets the compatibility level for the scheduled task. Defaults to Vista. ```APIDOC ## Compatibility ### Description The task compatibility level. ### Parameter Type Write ### Data Type String ### Default Value Vista ### Allowed Values `AT`, `V1`, `Vista`, `Win7`, `Win8` ``` -------------------------------- ### Run PowerShell Task Every 15 Minutes Source: https://github.com/dsccommunity/computermanagementdsc/wiki/ScheduledTask Configures a scheduled task to run a PowerShell script every 15 minutes for 4 days. The task starts immediately and runs as the local system account. All running tasks are stopped at the end of the repetition duration. ```powershell Configuration ScheduledTask_RunPowerShellTaskEvery15Minutes_Config { Import-DscResource -ModuleName ComputerManagementDsc Node localhost { ScheduledTask MaintenanceScriptExample { TaskName = "Custom maintenance tasks" ActionExecutable = "C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe" ActionArguments = "-File `"C:\scripts\my custom script.ps1`"" ScheduleType = 'Once' RepeatInterval = '00:15:00' RepetitionDuration = '4.00:00:00' StopAtDurationEnd = $true } } } ``` -------------------------------- ### Leave Domain and Join Workgroup Source: https://context7.com/dsccommunity/computermanagementdsc/llms.txt Configures a computer to leave its current domain and join a specified workgroup. Requires credentials for the operation. ```powershell #Requires -module ComputerManagementDsc Configuration Computer_UnjoinDomainAndJoinWorkgroup_Config { param ( [Parameter(Mandatory = $true)] [System.Management.Automation.PSCredential] $Credential ) Import-DscResource -Module ComputerManagementDsc Node localhost { Computer JoinWorkgroup { Name = 'Server01' WorkGroupName = 'ContosoWorkgroup' Credential = $Credential # Credential to unjoin from domain } } } ``` -------------------------------- ### SystemRestorePoint Resource Source: https://github.com/dsccommunity/computermanagementdsc/wiki/SystemRestorePoint This resource is used to create and delete restore points. System Protection must be enabled on at least one drive for this module to work. System restore points are only applicable to workstation operating systems. Server operating systems are not supported. ```APIDOC ## SystemRestorePoint Resource ### Description This resource is used to create and delete restore points. System Protection must be enabled on at least one drive for this module to work. System restore points are only applicable to workstation operating systems. Server operating systems are not supported. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **Ensure** (String) - Required - Indicates that the computer restore is enabled or is disabled. Allowed Values: `Present`, `Absent` - **Description** (String) - Optional - Specifies a descriptive name for the restore point. - **RestorePointType** (String) - Optional - Specifies the restore point type. Defaults to APPLICATION_INSTALL. Allowed Values: `APPLICATION_INSTALL`, `APPLICATION_UNINSTALL`, `DEVICE_DRIVER_INSTALL`, `MODIFY_SETTINGS`, `CANCELLED_OPERATION` ### Request Example ```powershell Configuration SystemRestorePoint_CreateModifySettings_Config { Import-DSCResource -ModuleName ComputerManagementDsc Node localhost { SystemRestorePoint ModifySettings { Ensure = 'Present' Description = 'Modify system settings' RestorePointType = 'MODIFY_SETTINGS' } } } ``` ### Response #### Success Response (200) This resource does not return a specific success response body, but operations are confirmed by the DSC engine. #### Response Example None ``` -------------------------------- ### Create a system restore point Source: https://github.com/dsccommunity/computermanagementdsc/wiki/SystemRestorePoint Configures a system restore point with the MODIFY_SETTINGS type. ```powershell Configuration SystemRestorePoint_CreateModifySettings_Config { Import-DSCResource -ModuleName ComputerManagementDsc Node localhost { SystemRestorePoint ModifySettings { Ensure = 'Present' Description = 'Modify system settings' RestorePointType = 'MODIFY_SETTINGS' } } } ``` -------------------------------- ### Create a Daily Scheduled Task with Repetition and Restart Source: https://github.com/dsccommunity/computermanagementdsc/wiki/ScheduledTask Use this configuration to create a daily scheduled task that repeats at a specified interval for a duration, with options for restarting on failure. Ensure the 'ComputerManagementDsc' module is imported. ```powershell Configuration ScheduledTask_CreateScheduledTaskDaily_Config { Import-DscResource -ModuleName ComputerManagementDsc Node localhost { ScheduledTask ScheduledTaskDailyAdd { TaskName = 'Test task Daily' TaskPath = '\MyTasks' ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' ScheduleType = 'Daily' DaysInterval = 1 RepeatInterval = '00:15:00' RepetitionDuration = '08:00:00' RestartCount = 2 RestartInterval = '00:05:00' RunOnlyIfNetworkAvailable = $true WakeToRun = $true } } } ``` -------------------------------- ### ActionExecutable Source: https://github.com/dsccommunity/computermanagementdsc/wiki/ScheduledTask Defines the full path to the executable file that the task will run. ```APIDOC ## ActionExecutable ### Description The path to the .exe for this task. ### Parameter Type Write ### Data Type String ``` -------------------------------- ### Recreate an SMB share Source: https://github.com/dsccommunity/computermanagementdsc/wiki/SmbShare Forces the recreation of an SMB share if it already exists. Uses default values for properties not explicitly defined. ```powershell Configuration SmbShare_RecreateShare_Config { Import-DscResource -ModuleName ComputerManagementDsc Node localhost { SmbShare 'RecreateShare' { Name = 'Share' Path = 'C:\Share1' Force = $true } } } ``` -------------------------------- ### Configure Paging File Settings Source: https://github.com/dsccommunity/computermanagementdsc/wiki/VirtualMemory This resource allows for the configuration of properties of the paging file on the local computer. You can set the drive, type of paging, initial size, and maximum size. ```APIDOC ## SET /api/computermanagementdsc/virtualmemory ### Description Configures the paging file settings for the local computer. ### Method SET ### Endpoint /dsccommunity/computermanagementdsc/virtualmemory ### Parameters #### Query Parameters - **Drive** (String) - Required - The drive letter for which paging settings should be set. Can be letter only, letter and colon or letter with colon and trailing slash. - **Type** (String) - Required - The type of the paging setting to use. If set to AutoManagePagingFile, the drive letter will be ignored. If set to SystemManagedSize, the values for InitialSize and MaximumSize will be ignored. Allowed Values: `AutoManagePagingFile`, `CustomSize`, `SystemManagedSize`, `NoPagingFile` - **InitialSize** (SInt64) - Optional - The initial size of the page file in Megabyte. - **MaximumSize** (SInt64) - Optional - The maximum size of the page file in Megabyte. ### Request Example ```json { "Drive": "C", "Type": "CustomSize", "InitialSize": 2048, "MaximumSize": 2048 } ``` ### Response #### Success Response (200) - **Status** (String) - Indicates the success of the operation. #### Response Example ```json { "Status": "Success" } ``` ``` -------------------------------- ### Join Computer to Domain Using ODJ Blob Source: https://github.com/dsccommunity/computermanagementdsc/wiki/OfflineDomainJoin Use this configuration to join a computer to an Active Directory domain by specifying the path to the ODJ request file. Ensure the 'ComputerManagementDsc' module is imported. ```powershell Configuration OfflineDomainJoin_JoinDomainUsingODJBlob_Config { Import-DscResource -ModuleName ComputerManagementDsc Node localhost { OfflineDomainJoin ODJ { IsSingleInstance = 'Yes' RequestFile = 'C:\ODJ\ODJBlob.txt' } } } ``` -------------------------------- ### Configure Application Log Size and Mode Source: https://github.com/dsccommunity/computermanagementdsc/wiki/WindowsEventLog Sets the Application log to a maximum size of 4096MB, sets the log mode to circular, and ensures it is enabled. ```powershell Configuration WindowsEventLog_SetLogSize_Config { Import-DSCResource -ModuleName ComputerManagementDsc Node localhost { WindowsEventLog Application { LogName = 'Application' IsEnabled = $true LogMode = 'Circular' MaximumSizeInBytes = 4096MB } } } ``` -------------------------------- ### Join Computer to a Domain Source: https://github.com/dsccommunity/computermanagementdsc/wiki/Computer This configuration joins a computer to a specified domain. It requires a mandatory credential parameter for domain authentication. Ensure the ComputerManagementDsc module is imported. ```powershell Configuration Computer_JoinDomain_Config { param ( [Parameter(Mandatory = $true)] [ValidateNotNullorEmpty()] [System.Management.Automation.PSCredential] $Credential ) Import-DscResource -Module ComputerManagementDsc Node localhost { Computer JoinDomain { Name = 'Server01' DomainName = 'Contoso' Credential = $Credential # Credential to join to domain } } } ``` -------------------------------- ### Create a Scheduled Task to Run Interactively as a User Source: https://github.com/dsccommunity/computermanagementdsc/wiki/ScheduledTask This configuration demonstrates how to create a scheduled task that runs once and executes using a provided credential. The task will only run when the specified user is logged on. ```powershell Configuration ScheduledTask_RunPowerShellTaskOnceAsUserInteractiveOnly_Config { param ( [Parameter(Mandatory = $true)] [ValidateNotNullorEmpty()] [System.Management.Automation.PSCredential] $Credential ) Import-DscResource -ModuleName ComputerManagementDsc Node localhost { ScheduledTask MaintenanceScriptExample { TaskName = 'Test task Interactive' TaskPath = '\MyTasks' ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' ScheduleType = 'Once' ActionWorkingPath = (Get-Location).Path Enable = $true ExecuteAsCredential = $Credential LogonType = 'Interactive' } } } ``` -------------------------------- ### Configure Granular UAC Settings Source: https://github.com/dsccommunity/computermanagementdsc/wiki/UserAccountControl Applies specific granular UAC registry settings including consent behavior and virtualization options. ```powershell Configuration UserAccountControl_GranularSettings_Config { Import-DscResource -Module ComputerManagementDsc Node localhost { UserAccountControl 'SetGranularSettings' { IsSingleInstance = 'Yes' FilterAdministratorToken = 0 ConsentPromptBehaviorAdmin = 5 ConsentPromptBehaviorUser = 3 EnableInstallerDetection = 1 ValidateAdminCodeSignatures = 0 EnableLua = 1 PromptOnSecureDesktop = 1 EnableVirtualization = 1 } } } ``` -------------------------------- ### Create System Restore Point Source: https://context7.com/dsccommunity/computermanagementdsc/llms.txt Creates or deletes system restore points when System Protection is enabled. ```powershell #Requires -module ComputerManagementDsc Configuration SystemRestorePoint_CreateModifySettings_Config { Import-DSCResource -ModuleName ComputerManagementDsc Node localhost { SystemRestorePoint ModifySettings { Ensure = 'Present' Description = 'Modify system settings' RestorePointType = 'MODIFY_SETTINGS' } } } ``` -------------------------------- ### Configure Windows Event Log Mode Source: https://github.com/dsccommunity/computermanagementdsc/wiki/WindowsEventLog Sets the MSPaint Admin event channel to AutoBackup mode with specific size and retention settings. ```powershell Configuration WindowsEventLog_SetLogMode_Config { Import-DSCResource -ModuleName ComputerManagementDsc Node localhost { WindowsEventLog MSPaintAdmin { LogName = 'Microsoft-Windows-MSPaint/Admin' IsEnabled = $true LogMode = 'AutoBackup' LogRetentionDays = 10 MaximumSizeInBytes = 2048KB } } } ``` -------------------------------- ### Set Active Power Plan Configuration Source: https://github.com/dsccommunity/computermanagementdsc/wiki/PowerPlan Configures the system to use the 'High performance' power plan. Requires the ComputerManagementDsc module to be imported. ```powershell Configuration PowerPlan_SetPowerPlan_Config { Import-DscResource -ModuleName ComputerManagementDsc Node localhost { PowerPlan SetPlanHighPerformance { IsSingleInstance = 'Yes' Name = 'High performance' } } } ``` -------------------------------- ### Configure Virtual Memory with Custom Size Source: https://github.com/dsccommunity/computermanagementdsc/wiki/VirtualMemory Sets the paging file to a custom size of 2048MB on the C drive using the VirtualMemory resource. ```powershell Configuration VirtualMemory_SetVirtualMemory_Config { Import-DSCResource -ModuleName ComputerManagementDsc Node localhost { VirtualMemory PagingSettings { Type = 'CustomSize' Drive = 'C' InitialSize = '2048' MaximumSize = '2048' } } } ``` -------------------------------- ### Configure Computer Name and Workgroup Membership Source: https://github.com/dsccommunity/computermanagementdsc/wiki/Computer Use this configuration to set the computer's name and assign it to a workgroup. Ensure the ComputerManagementDsc module is imported. ```powershell Configuration Computer_RenameComputerAndSetWorkgroup_Config { Import-DscResource -Module ComputerManagementDsc Node localhost { Computer NewNameAndWorkgroup { Name = 'Server01' WorkGroupName = 'ContosoWorkgroup' } } } ``` -------------------------------- ### ActionArguments Source: https://github.com/dsccommunity/computermanagementdsc/wiki/ScheduledTask Specifies the arguments to be passed to the executable when the task runs. ```APIDOC ## ActionArguments ### Description The arguments to pass the executable. ### Parameter Type Write ### Data Type String ``` -------------------------------- ### Unjoin Domain and Join Workgroup Source: https://github.com/dsccommunity/computermanagementdsc/wiki/Computer This configuration switches a computer from a domain to a workgroup. It requires a credential with permissions to unjoin the computer from the domain. Ensure the ComputerManagementDsc module is imported. ```powershell Configuration Computer_UnjoinDomainAndJoinWorkgroup_Config { param ( [Parameter(Mandatory = $true)] [ValidateNotNullorEmpty()] [System.Management.Automation.PSCredential] $Credential ) Import-DscResource -Module ComputerManagementDsc Node localhost { Computer JoinWorkgroup { Name = 'Server01' WorkGroupName = 'ContosoWorkgroup' Credential = $Credential # Credential to unjoin from domain } } } ``` -------------------------------- ### Create Weekly Scheduled Task Source: https://context7.com/dsccommunity/computermanagementdsc/llms.txt Creates a weekly scheduled task that can be configured to run on specific days of the week with repetition. Supports battery power and hidden task options. ```powershell #Requires -module ComputerManagementDsc # Weekly scheduled task Configuration ScheduledTask_CreateScheduledTasksWeekly_Config { Import-DscResource -ModuleName ComputerManagementDsc Node localhost { ScheduledTask ScheduledTaskWeeklyAdd { TaskName = 'Test task Weekly' TaskPath = '\MyTasks' ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' ScheduleType = 'Weekly' WeeksInterval = 1 DaysOfWeek = 'Monday', 'Wednesday', 'Saturday' RepeatInterval = '00:15:00' RepetitionDuration = '08:00:00' AllowStartIfOnBatteries = $true Compatibility = 'Win8' Hidden = $true } } } ``` -------------------------------- ### Configure System Protection Source: https://context7.com/dsccommunity/computermanagementdsc/llms.txt Enables System Protection (System Restore) and configures disk space usage for restore points on workstations. ```powershell #Requires -module ComputerManagementDsc Configuration SystemProtection_EnableDriveC_Config { Import-DSCResource -ModuleName ComputerManagementDsc Node localhost { SystemProtection DriveC { Ensure = 'Present' DriveLetter = 'C' } } } ``` -------------------------------- ### Retrieve valid Windows System Locales Source: https://github.com/dsccommunity/computermanagementdsc/wiki/SystemLocale Use this command to list all available culture names for the SystemLocale parameter. ```powershell [System.Globalization.CultureInfo]::GetCultures([System.Globalization.CultureTypes]::AllCultures).name ``` -------------------------------- ### Enable System Protection for Drive C with 5% Disk Usage Source: https://github.com/dsccommunity/computermanagementdsc/wiki/SystemProtection Enables system protection for the C drive and sets the maximum restore point disk usage to 5 percent. Ensure the ComputerManagementDsc module is imported. ```powershell Configuration SystemProtection_EnableDriveC_5Percent_Config { Import-DSCResource -ModuleName ComputerManagementDsc Node localhost { SystemProtection DriveC { Ensure = 'Present' DriveLetter = 'C' DiskUsage = 5 } } } ``` -------------------------------- ### Create a Scheduled Task to Run Once Source: https://github.com/dsccommunity/computermanagementdsc/wiki/ScheduledTask This configuration creates a scheduled task that runs once, with a specified repeat interval and duration. It also includes settings for random delay, preventing hard termination of previous instances, and no execution time limit. ```powershell Configuration ScheduledTask_CreateScheduledTaskOnce_Config { Import-DscResource -ModuleName ComputerManagementDsc Node localhost { ScheduledTask ScheduledTaskOnceAdd { TaskName = 'Test task Once' TaskPath = '\MyTasks' ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' ScheduleType = 'Once' RepeatInterval = '00:15:00' RepetitionDuration = '08:00:00' ExecutionTimeLimit = '00:00:00' ActionWorkingPath = (Get-Location).Path Enable = $true RandomDelay = '01:00:00' DisallowHardTerminate = $true RunOnlyIfIdle = $false Priority = 9 } } } ``` -------------------------------- ### Create Daily Scheduled Task Source: https://context7.com/dsccommunity/computermanagementdsc/llms.txt Creates a daily scheduled task that can be configured to repeat and restart on failure. Supports network availability and wake-to-run options. ```powershell #Requires -module ComputerManagementDsc # Daily scheduled task with restart on failure Configuration ScheduledTask_CreateScheduledTaskDaily_Config { Import-DscResource -ModuleName ComputerManagementDsc Node localhost { ScheduledTask ScheduledTaskDailyAdd { TaskName = 'Test task Daily' TaskPath = '\MyTasks' ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' ScheduleType = 'Daily' DaysInterval = 1 RepeatInterval = '00:15:00' RepetitionDuration = '08:00:00' RestartCount = 2 RestartInterval = '00:05:00' RunOnlyIfNetworkAvailable = $true WakeToRun = $true } } } ``` -------------------------------- ### Configure Windows Event Log Settings Source: https://context7.com/dsccommunity/computermanagementdsc/llms.txt Use the WindowsEventLog resource to set the maximum size and retention mode for Windows event logs. Ensure the ComputerManagementDsc module is imported. ```powershell #Requires -module ComputerManagementDsc Configuration WindowsEventLog_SetLogSize_Config { Import-DSCResource -ModuleName ComputerManagementDsc Node localhost { WindowsEventLog Application { LogName = 'Application' IsEnabled = $true LogMode = 'Circular' MaximumSizeInBytes = 4096MB } } } ``` -------------------------------- ### Create Scheduled Task as NETWORK SERVICE Source: https://github.com/dsccommunity/computermanagementdsc/wiki/ScheduledTask Creates a scheduled task that runs every 15 minutes as the 'NETWORK SERVICE' account. The task writes the current username to a file. ```powershell Configuration ScheduledTask_CreateScheduledTasksAsBuiltInServiceAccount_Config { Import-DscResource -ModuleName ComputerManagementDsc Node localhost { ScheduledTask ScheduledTaskAsNetworkService { TaskName = 'Test As NetworkService' Ensure = 'Present' ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' ActionArguments = '-Command Set-Content -Path c:\temp\seeme.txt -Value $env:USERNAME -Force' ScheduleType = 'Once' RepeatInterval = '00:15:00' RepetitionDuration = '4.00:00:00' BuiltInAccount = 'NETWORK SERVICE' } } } ``` -------------------------------- ### ActionWorkingPath Source: https://github.com/dsccommunity/computermanagementdsc/wiki/ScheduledTask Sets the working directory for the executable when the task is executed. ```APIDOC ## ActionWorkingPath ### Description The working path to specify for the executable. ### Parameter Type Write ### Data Type String ``` -------------------------------- ### Enable and Configure DSC Analytic Log Source: https://github.com/dsccommunity/computermanagementdsc/wiki/WindowsEventLog Configures the DSC Analytic log with a specific size, retention mode, and file path. ```powershell Configuration WindowsEventLog_EnableWindowsEventLog_Config { Import-DSCResource -ModuleName ComputerManagementDsc Node localhost { WindowsEventLog DscAnalytic { LogName = 'Microsoft-Windows-Dsc/Analytic' IsEnabled = $true LogMode = 'Retain' MaximumSizeInBytes = 4096MB LogFilePath = '%SystemRoot%\System32\Winevt\Logs\Microsoft-Windows-DSC%4Analytic.evtx' } } } ```