Skip to content

Troubleshoot

Splaxi edited this page Oct 15, 2021 · 5 revisions

Record a PowerShell session

Start-Transcript -Path "C:\Temp\PowerShellSession.log" -Append

Gathering logs

Get-PSFMessage -Errors | Format-List
Get-PSFMessage -Errors | Format-List | Out-file c:\temp\errors.txt

Get-PSFMessage -Level InternalComment | Format-List
Get-PSFMessage -Level InternalComment | Format-List | out-file C:\temp\sqlcommands.txt

Locate the folder where the module is installed

explorer.exe (Split-Path $(Get-Module d365fo.tools -ListAvailable | Select-Object -First 1).Path -Parent)

Unsplat a hashtable to a string with parameters

($HashArray.Keys | ForEach-Object {"-$($_) `"$($HashArray.Item($_))`""}) -Join " "

Debug

For general PowerShell debug information, see How to debug scripts in Windows PowerShell ISE.

To debug a cmdlet, first make sure the module is loaded with the individual files. Then open the .ps1 file of the cmdlet in PowerShell ISE and set a breakpoint. Finally, call the cmdlet.

Clone this wiki locally