Get file version in PowerShell

Since PowerShell can call .NET classes, you could do the following: Or as noted here on a list of files: Or even nicer as a script: https://jtruher3.wordpress.com/2006/05/14/powershell-and-file-version-information/

Simple PowerShell LastWriteTime compare

Try the following. This is part of the item property weirdness. When you run Get-ItemProperty it does not return the value but instead the property. You have to use one more level of indirection to get to the value.

How do I force Robocopy to overwrite files?

In general, Robocopy ignores files for which lastwrittendate and filesize are the same. How can we escape this design? I’d like to force overwriting with Robocopy. I expected that dst\sample.txt should be written test001. But these file are recognized as the same files by Robocopy and not overwritten. The “/IS” option is not effective in … Read more

How to convert string to integer in PowerShell

You can specify the type of a variable before it to force its type. It’s called (dynamic) casting (more information is here): As an example, the following snippet adds, to each object in $fileList, an IntVal property with the integer value of the Name property, then sorts $fileList on this new property (the default is … Read more

Difference between $? and $LastExitCode in PowerShell

$LastExitCode is the return code of native applications. $? just returns True or False depending on whether the last command (cmdlet or native) exited without error or not. For cmdlets failure usually means an exception, for native applications it’s a non-zero exit code: Cancelling a cmdlet with Ctrl+C will also count as failure; for native applications it depends on what exit code they set.

How to enter a multi-line command

You can use a space followed by the grave accent (backtick): However, this is only ever necessary in such cases as shown above. Usually you get automatic line continuation when a command cannot syntactically be complete at that point. This includes starting a new pipeline element: will work without problems since after the | the … Read more

What does the double asterisks mean?

Actually, I believe the above answer is wrong. Assume we have the following directory structure: dbl_wc (top level) –one_level_in –aa.txt –one_level_in1 –bb.txt –deeper_dir –abc.txt Copy-Item .\dbl_wc\**\*.txt copy_target -Force Will only look for *.txt in any directory under .\dbl_wc. And it won’t look in sub-directories (so for example .\dbl_wc\one_level_in1\deeper_dir). So it will get both aa.txt and … Read more

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