Textbook: Windows PowerShell in Action (E3, 2017) - pp. 2 and 3.
Executing the below three blocks of code below produces the subsequent three errors, respectively.
I recognise this is likely a straightfoward resolution, however am a newcomer to PowerShell and my spending significant time attempting to understand why introductory examples do not work at this premature stage of learning is a frustration.
Thank you in advance if you can assist.
More details available on request.
Code block #1:
Get-ChildItem -Path $env::windir\*.log |
Select-String -List error |
Format-Table Path,LineNumber -AutoSize
Code block #1 - Error:
Get-ChildItem : Second path fragment must not be a drive or UNC name. Parameter name: path2 At line:1 char:1 + Get-ChildItem -Path $env::windir\*.log | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (C:\Windows\system32:String) [Get-ChildItem], ArgumentException + FullyQualifiedErrorId : DirArgumentError,Microsoft.PowerShell.Commands.GetChildItemCommand
Code block #2:
([xml] [System.Net.WebClient]::new().
DownloadString('https://blogs.msdn.microsoft.com/powershell/feed.aspx')).
RSS.Channel.Item |
Format-Table table,link
Code block #2 - Error:
Method invocation failed because [System.Net.WebClient] does not contain a method named 'new'. At line:1 char:1 + ([xml] [System.Net.WebClient]::new(). + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : MethodNotFound
Code block #3:
using namespace System.Windows.Forms
$Form = [Form] @{
Text = 'My First Form'
}
$button = [Button] @{
Text = 'Push Me!'
Dock = 'Fill'
}
$button.add_click{
$form.Close()
}
$form.Controls.Add($button)
$form.ShowDialog()
Code block #3 - Error:
At line:1 char:1 + using assembly System.Windows.Forms + ~~~~~ The 'using' keyword is not supported in this version of the language. At line:2 char:1 + using namespace System.Windows.Forms + ~~~~~ The 'using' keyword is not supported in this version of the language. + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : ReservedKeywordNotAllowed