COOKIES! This blog uses cookies!
I am completely out of control of cookies here, otherwise I would have disabled them (it is controlled by the platform).
If you don't like cookies and being tracked please leave this blog immediately.

Showing posts with label powershell. Show all posts
Showing posts with label powershell. Show all posts

Saturday, 30 June 2018

Diff two files with powershell

Compare-Object -ReferenceObject $(Get-Content f1.txt) -DifferenceObject $(Get-Content f2.txt)

Thursday, 31 August 2017

Input redirection with powershell

PowerShell doesn't support input redirection, so it's impossible to do sql file import in usual way without invoking legacy CMD:
PS> mysql dbname < file.sql
At line:1 char:7
+ mysql < .\file.sql
+       ~
The '<' operator is reserved for future use.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException

    + FullyQualifiedErrorId : RedirectionNotSupported

Luckily it is possible to redirect input by taking file contents, which is, probably, more natural way to do:
PS> Get-Content .\file.sql | mysql dbname