Skip to content

Instantly share code, notes, and snippets.

@savishy
Last active March 15, 2022 17:06
Show Gist options
  • Select an option

  • Save savishy/94cf398b56d1700e08b8d20311a1f83f to your computer and use it in GitHub Desktop.

Select an option

Save savishy/94cf398b56d1700e08b8d20311a1f83f to your computer and use it in GitHub Desktop.

Revisions

  1. savishy revised this gist Jul 31, 2018. No changes.
  2. savishy revised this gist Jul 31, 2018. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions Powershell.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    ## Get Tail-Like Functionality in Windows!

    `Get-Content C:\Path\To\Log.txt -Wait`
  3. savishy revised this gist Jun 13, 2018. 1 changed file with 9 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions Powershell DSC.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,7 @@
    ### Enable Debug Logging if you want to see verbose logs.
    https://blogs.technet.microsoft.com/heyscriptingguy/2014/10/16/use-powershell-and-dsc-to-enable-logging/
    You can also enable Debug and Analytic logs in Windows Event Logging. https://blogs.msdn.microsoft.com/powershell/2014/01/03/using-event-logs-to-diagnose-errors-in-desired-state-configuration/

    ### How do I kill a running DSC process?

    E.g. if you want to reapply a DSC resource
    @@ -10,6 +14,11 @@ gps wmi* | ? {$_.modules.ModuleName -like "*DSC*"} | stop-process -force

    ### How do I view status of DSC operations?

    Ref: https://docs.microsoft.com/en-us/powershell/dsc/troubleshooting#using-xdscdiagnostics-to-analyze-dsc-logs

    Note: you need a DSC Module for this: https://github.com/PowerShell/xDscDiagnostics
    Install it `Install-Module -Name xDscDiagnostics`, then import it into your session as `Import-Module -Name xDscDiagnostics`.

    Get the tasks that failed:

    ```
  4. savishy revised this gist Jun 13, 2018. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions Powershell DSC.md
    Original file line number Diff line number Diff line change
    @@ -35,6 +35,7 @@ C:\Windows\System32\Configuration\ConfigurationStatus
    * The relevant filename contains the `JobID` of the failed job.

    **Read the output with `more`**
    E.g. `more "C:\Windows\System32\Configuration\ConfigurationStatus\{FF0A92A6-6ED8-11E8-A94A-000D3AB266F4}-0.details.json"`

    ```
    {"time": "2018-06-13T07:11:35.492+00:00", "type": "verbose", "message": "[VVSPPOCDB2]: [[xSqlServer]DirectResourceAccess] Changing the SQL system database default log path to 'L:\\LOGS' ..."},
  5. savishy revised this gist Jun 13, 2018. 1 changed file with 16 additions and 0 deletions.
    16 changes: 16 additions & 0 deletions Powershell DSC.md
    Original file line number Diff line number Diff line change
    @@ -34,3 +34,19 @@ C:\Windows\System32\Configuration\ConfigurationStatus
    * Outputs are stored in JSON files.
    * The relevant filename contains the `JobID` of the failed job.

    **Read the output with `more`**

    ```
    {"time": "2018-06-13T07:11:35.492+00:00", "type": "verbose", "message": "[VVSPPOCDB2]: [[xSqlServer]DirectResourceAccess] Changing the SQL system database default log path to 'L:\\LOGS' ..."},
    {"time": "2018-06-13T07:11:35.492+00:00", "type": "verbose", "message": "[VVSPPOCDB2]: [[xSqlServer]DirectResourceAccess] Changing the SQL system database default file path to 'F:\\DATA' ..."},
    {"time": "2018-06-13T07:11:35.555+00:00", "type": "error", "message": "F:\\DATA: The system cannot find the file specified."},
    {"time": "2018-06-13T07:11:35.586+00:00", "type": "error", "message": "L:\\LOGS: The system cannot find the file specified."},
    {"time": "2018-06-13T07:11:38.935+00:00", "type": "verbose", "message": "[VVSPPOCDB2]: [[xSqlServer]DirectResourceAccess] Changed database context to 'master'."},
    {"time": "2018-06-13T07:11:38.950+00:00", "type": "error", "message": "The path specified by \"F:\\DATA\\tempdb.mdf\" is not in a valid directory."},
    {"time": "2018-06-13T07:11:38.950+00:00", "type": "error", "message": "The path specified by \"L:\\LOGS\\templog.ldf\" is not in a valid directory."},
    {"time": "2018-06-13T07:11:38.966+00:00", "type": "error", "message": "The path specified by \"F:\\DATA\\model.mdf\" is not in a valid directory."},
    {"time": "2018-06-13T07:11:38.966+00:00", "type": "error", "message": "The path specified by \"L:\\LOGS\\modellog.ldf\" is not in a valid directory."},
    {"time": "2018-06-13T07:11:38.966+00:00", "type": "error", "message": "The path specified by \"F:\\DATA\\msdbdata.mdf\" is not in a valid directory."},
    {"time": "2018-06-13T07:11:38.982+00:00", "type": "error", "message": "The path specified by \"L:\\LOGS\\msdblog.ldf\" is not in a valid directory."},
    {"time": "2018-06-13T07:11:40.138+00:00", "type": "error", "message": "Exception setting \"StartupParameters\": \"STARTUPPARAMETERS: unknown property.\""},
    ```
  6. savishy revised this gist Jun 13, 2018. No changes.
  7. savishy created this gist Jun 13, 2018.
    36 changes: 36 additions & 0 deletions Powershell DSC.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    ### How do I kill a running DSC process?

    E.g. if you want to reapply a DSC resource

    ```
    rm C:\windows\system32\Configuration\*.mof*
    gps wmi* | ? {$_.modules.ModuleName -like "*DSC*"} | stop-process -force
    ```


    ### How do I view status of DSC operations?

    Get the tasks that failed:

    ```
    PS > Get-xDscOperation
    ComputerName SequenceId TimeCreated Result JobID AllEvents
    ------------ ---------- ----------- ------ ----- ---------
    VVAAPOCDB2 1 6/13/2018 7:13:43 AM Failure ff0a92a6-6ed8-11e8-a94a-000d3ab266f4 {@{Message=Deletin...
    VVAAPOCDB2 2 6/13/2018 5:57:06 AM Failure 99ac233d-6ece-11e8-a94a-000d3ab266f4 {@{Message=Getting...
    VVAAPOCDB2 3 6/13/2018 5:57:11 AM Success 99ac233e-6ece-11e8-a94a-000d3ab266f4 {@{Message=Getting...
    VVAAPOCDB2 4 6/13/2018 5:57:15 AM Success 99ac233f-6ece-11e8-a94a-000d3ab266f4 {@{Message=Getting...
    ```
    Use its `JobID` to trace it.

    `Trace-xDscOperation -JobId ff0a92a6-6ed8-11e8-a94a-000d3ab266f4`

    ### Where do the raw logs of `Invoke-DSCResource` go?
    Ref: https://stackoverflow.com/questions/37177678/desired-state-configuration-verbose-logging

    C:\Windows\System32\Configuration\ConfigurationStatus

    * Outputs are stored in JSON files.
    * The relevant filename contains the `JobID` of the failed job.