I just installed Powershell on Linux, this was very easy, using a provided RPM file.
This is Powershell version 7.4.1: https://github.com/PowerShell/PowerShell/releases/download/v7.4.1/powershell-7.4.1-1.rh.x86_64.rpm.
(jcartwright@2403-4800-25af-b00--2) 192.168.1.5 Downloads $ su
Password:
[root@2403-4800-25af-b00--2 Downloads]# rpm -ivh powershell-7.4.1-1.rh.x86_64.rpm
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:powershell-7.4.1-1.rh ################################# [100%]
This is very simple. Then I could easily run Powershell and print the Powershell version.
(jcartwright@2403-4800-25af-b00--2) 192.168.1.5 Downloads $ pwsh
PowerShell 7.4.1
PS /home/jcartwright/Downloads> get-host
Name : ConsoleHost
Version : 7.4.1
InstanceId : 4e2b06f9-2e66-41e7-ba1e-7454433c9bd7
UI : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture :
CurrentUICulture :
PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled : True
IsRunspacePushed : False
Runspace : System.Management.Automation.Runspaces.LocalRunspace
This can print the clipboard very easily and would be very useful for running Windows Powershell scripts on Linux.
PS /home/jcartwright/Downloads> Get-Clipboard <pre>(<font color="#FF00D7"><b>jcartwright</b></font>@<font color="#5FAFD7"><b>2403-4800-25af-b00--2</b></font>) <font color="#FFD700"><b>192.168.1.5 Downloads </b></font><span style="text-decoration-line:overline"><font color="#8787FF"><b> $ </b></font></span>pwsh PowerShell 7.4.1 PS /home/jcartwright/Downloads> <font color="#FFFF55">get-host</font> <font color="#00AA00"><b>Name : </b></font>ConsoleHost <font color="#00AA00"><b>Version : </b></font>7.4.1 <font color="#00AA00"><b>InstanceId : </b></font>4e2b06f9-2e66-41e7-ba1e-7454433c9bd7 <font color="#00AA00"><b>UI : </b></font>System.Management.Automation.Internal.Host.InternalHostUserInterface <font color="#00AA00"><b>CurrentCulture : </b></font> <font color="#00AA00"><b>CurrentUICulture : </b></font> <font color="#00AA00"><b>PrivateData : </b></font>Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy <font color="#00AA00"><b>DebuggerEnabled : </b></font>True <font color="#00AA00"><b>IsRunspacePushed : </b></font>False <font color="#00AA00"><b>Runspace : </b></font>System.Management.Automation.Runspaces.LocalRunspace</pre>
This can even print the uptime of your machine.
PS /home/jcartwright/Desktop> Get-Uptime Days : 0 Hours : 2 Minutes : 24 Seconds : 46 Milliseconds : 0 Ticks : 86860000000 TotalDays : 0.100532407407407 TotalHours : 2.41277777777778 TotalMinutes : 144.766666666667 TotalSeconds : 8686 TotalMilliseconds : 8686000
Powershell may be used for web scraping as well. This is very useful for extracting data from a website.
PS /home/jcartwright/Desktop> ([regex]::Matches((Invoke-RestMethod "https://www.dailytelegraph.com.au/news/nsw"), '(?<=data-tgev-container="feed-1">).*?(?=</a>)') | ForEach-Object { $_.Value }) ‘Reason for living’: Mum mourns lawyer found dead on Sydney street Fresh detail revealed in hiring of top cop’s new spin doctor Claims brumbies left to die in ‘botched killing spree’ Only $1000 to go: PM’s power failure as bills keep rising Missing billions: GST carve up costing NSW 10,000 cops, nurses Rates Stay Steady 20/03/2024 Daily Telegraph – News Feed New home builds hit record low $850k bill to clean up immigration detainee disaster SENSITIVE: Brumbies aerial culled at Kosciuszko National Park Realtor accidentally burns down home Mother drowns rescuing daughter in south coast beach tragedy Pressure on Karen Webb over new media chief Senior MP quizzed as TikTok habits spark security fears Trump’s problem with cash ‘$25k is all you need to buy a home’ Tiny schoolgirl speedster Waiaria Ellis creates footy history Bye-bye boogie: Mystery surrounds beloved Byron nightclub’s shock closure Man critical as neighbours’ dog row ends in alleged hit-and-run The terrifying day Chopper Read nearly ‘ended me’ Massive rent-only apartment complex opens in city’s west Flooded and dudded: more migrants, less GST bucks for NSW ‘Blame game’ over NSW top cop’s new spin doctor 40 flee unit complex after e-bike battery blaze Labor boots security bosses from key intelligence body
Another example. This is selecting certain HTML tags to extract the data from between them.
PS /home/jcartwright/Desktop> ([regex]::Matches((Invoke-RestMethod "https://www.news.com.au/"), '(?<=data-tgev-container="tops">).*?(?=</a>)') | ForEach-Object { $_.Value }) PRINCE’S HUGE FAIL: William exposed by new video of Kate Middleton Entire school bulldozed after disturbing find ‘Major’ breach over Kate’s medical records Couple’s horrific act while drunk on beach Another Kate photo confirmed to be ‘edited’ Karl, Campbell tear Olympics to shreds Nicole Kidman’s racy new mag photo shoot Homeowner arrested trying to evict squatter Tragedy as man dies after snake bite ‘Nasty’: Trump’s warning to Kevin Rudd Police announce star’s tragic cause of death Elite headmaster goes on ‘wokeness’ rant Aussie flight sale with $355 fares to Europe $152 machine that’s ‘like a cafe at home’
This is missing some modules such as NetAdapter, but it is still very usable.