上QQ阅读APP看书,第一时间看更新
How to do it...
Please perform the following steps:
- Review the output of Get-Command -Verb New,Set,Remove,Register,Unregister,Start,Stop to review some of the more frequently used cmdlets.
- Execute $file = New-TemporaryFile to create a temporary file.
- Use 'SomeContent' | Set-Content -Path $file to change the file contents.
- Use 'More content!' | Add-Content -Path $file to append data to the file.
- Review the contents with $file | Get-Item | Get-Content -Path.
- Lastly use $file | Remove-Item -Verbose to get rid of the file again.
- Use $ping = Start-Process -FilePath ping -ArgumentList 'packtpub.com' -PassThru.
- Use $ping | Stop-Process -PassThru to stop the background process.
- Use Start-Job -Name Sleepy { Start-Sleep -Seconds 100; Get-Date}.
- Have a look at the job with Get-Job -Name Sleepy—is it ready to deliver the data?
- Use Get-Job -Name Sleepy | Wait-Job to wait for the results.
- Lastly, use Get-Job -Name Sleepy | Receive-Job -Keep to gather the results.
- As an alternative, try $job = Get-ChildItem -Recurse -Force -Path $home & and $job | Wait-Job | Receive-Job.
- Clean up any remaining jobs by closing PowerShell or executing $job | Remove-Job; Get-Job -Name Sleepy | Remove-Job.