Am trying to echo a string and encode using base64 by getting the echoed string as input.
Write-Host "Hello World" | $b = [System.Convert]::FromBase64String($_) ; [System.Text.Encoding]::UTF8.GetString($b)
But getting below error,
At line:1 char:28
+ Write-Host "Hello World" | $b = [System.Convert]::FromBase64String($_) ; [System ...
+ ~~
Expressions are only allowed as the first element of a pipeline.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : ExpressionsMustBeFirstInPipeline
Any idea for this