PowerShell: how to count number of rows in csv file?

Get-Content and Measure-Object are fine for small files, but both are super inefficient with memory. I had real problems with large files. When counting rows in a 1GB file using either method, Powershell gobbled up all available memory on the server (8GB), then started paging to disk. I left it over an hour, but it … Read more

How to perform keystroke inside powershell?

If I understand correctly, you want PowerShell to send the ENTER keystroke to some interactive application? $wshell = New-Object -ComObject wscript.shell; $wshell.AppActivate(‘title of the application window’) Sleep 1 $wshell.SendKeys(‘~’) If that interactive application is a PowerShell script, just use whatever is in the title bar of the PowerShell window as the argument to AppActivate (by … Read more

How can I find the source path of an executing script? [duplicate]

The ubiquitous script originally posted by Jeffrey Snover of the PowerShell team (given in Skyler’s answer) and the variations posted by Keith Cedirc, and EBGreen, all suffer from a serious drawback–whether the code reports what you expect depends on where you call it! My code below overcomes this problem by simply referencing script scope instead … Read more

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