How can I specify the column ordering when exporting to CSV in PowerShell?

gvee’s helpful answer is a pragmatic solution that ensures that the columns appear in the desired order, because the order in which you pass property names to Select-Object is the order in which the properties are added to the resulting [pscustomobject] instances. It is, however, inefficient, because the desired column order can be ensured at … Read more

When to choose development of a PowerShell Module over PowerShell Script

To understand what modules can do for you, read this: https://learn.microsoft.com/en-us/powershell/scripting/developer/module/writing-a-windows-powershell-module?view=powershell-7.1 In a nutshell, Windows PowerShell modules allow you to partition, organize, and abstract your Windows PowerShell code into self-contained, reusable units. With these reusable units, administrators, script developers, and cmdlet developers can easily share their modules directly with others. Script developers can also repackage … Read more

Powershell: get output from Receive-Job

If the job uses Write-Host to produce output, Receive-Job returns $null, but the results get written to the host. However, if the job uses Write-Output to produce output in lieu of Write-Host, Receive-Job returns a string array [string[]] of the job output. To demonstrate, enter this innocuous code at the PowerShell prompt: $job = Start-Job … Read more

Is there a way to specify a font color when using write-output

I have tried this extra function and it basically works fine: function Write-ColorOutput($ForegroundColor) { # save the current color $fc = $host.UI.RawUI.ForegroundColor # set the new color $host.UI.RawUI.ForegroundColor = $ForegroundColor # output if ($args) { Write-Output $args } else { $input | Write-Output } # restore the original color $host.UI.RawUI.ForegroundColor = $fc } # test … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)