The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,421 other followers

Archive for the ‘PowerShell’ Category

No it was not possible to install PowerShell 3 on a Windows Server 2003 or 2003 R2? – Super User

Posted by jpluimers on 2018/08/28

Since it was not possible to install PowerShell 3 on ancient Windows Server 2003 and Windows Server 2003 R2 machines, I opted for this workaround during the time they were being retired:

I’ve investigating how much work it will be to migrate the machine, as opposed to adapting the scripts with Poshcode/Jaykul modules (of which many have external dependencies that I’d need to check first). It’s about the same order of magnitude, so I’ll be migrating the machine earlier. In the mean time, a different machine will run the scripts and access the required data over a network share.

Source: [WayBackIs it possible to install PowerShell 3 on a Windows Server 2003 or 2003 R2? – Super User

Posted in CommandLine, Development, PowerShell, PowerShell, Scripting, Software Development | Leave a Comment »

PowerShell on Mac OS X and other non-Windows systems

Posted by jpluimers on 2018/07/17

I wasn’t expecting it to be so easy to install PowerShell on Mac OS X:

brew install Caskroom/cask/powershell

In the background it executes this script: https://github.com/caskroom/homebrew-cask/blob/master/Casks/powershell.rb. which indirectly goes through the URL template https://github.com/PowerShell/PowerShell/releases/download/v#{version}/powershell-#{version}.pkg.

On other non-Windows systems, you have to go through GitHub yourself: https://github.com/powershell/PowerShell. The PowerShell team at Microsoft has many more repositories including the Win32-OpenSSH port which you can find through https://github.com/PowerShell.

At the time of writing, PowerShell was available for these platforms:

Platform Downloads How to Install
Windows 10 / Server 2016 (x64) .msi Instructions
Windows 8.1 / Server 2012 R2 (x64) .msi Instructions
Windows 7 (x64) .msi Instructions
Windows 7 (x86) .msi Instructions
Ubuntu 16.04 .deb Instructions
Ubuntu 14.04 .deb Instructions
CentOS 7 .rpm Instructions
OpenSUSE 42.1 .rpm Instructions
Arch Linux Instructions
Many Linux distributions .AppImage Instructions
macOS 10.11 .pkg Instructions
Docker Instructions

The first version I installed on Mac OS X was this: ==> Downloading https://github.com/PowerShell/PowerShell/releases/download/v6.0.0-alpha.17/powershell-6.0.0-alpha.17.pkg

By now I really hope it is out of Alpha state.

–jeroen

via:

Posted in *nix, Apple, CommandLine, Development, iMac, Linux, Mac, Mac OS X / OS X / MacOS, MacBook, MacBook Retina, MacBook-Air, MacBook-Pro, MacMini, openSuSE, Power User, PowerShell, PowerShell, Scripting, Software Development, SuSE Linux, Ubuntu | Leave a Comment »

Mad With PowerShell

Posted by jpluimers on 2018/06/25

Cool blog:

[WayBackMad With PowerShell Tim Curwick’s PowerShell blog, tips and tricks, tools and techniques, explanations and explorations

via: [WayBack] Mad With PowerShell – Excellent blog by +Tim Curwick about the use and abuse of PowerShell, and brimming with good examples and clues. – Lars Fosdal – Google+

–jeroen

 

Posted in CommandLine, Development, PowerShell, PowerShell, Scripting, Software Development | Leave a Comment »

PowerShell – query reboot/shutdown events

Posted by jpluimers on 2018/06/19

Thanks [WayBackgbabu for the below PowerShell ide

As PowerShell command:

Get-EventLog System | Where-Object {$_.EventID -eq "1074" -or $_.EventID -eq "6008" -or $_.EventID -eq "1076"} | ft Machinename, TimeWritten, UserName, EventID, Message -AutoSize -Wrap

Based on it and my own experience, thse Event IDs can be interesting:

  • 41 – The system has rebooted without cleanly shutting down first
  • 109 – The kernel power manager has initiated a shutdown transition.
  • 1073 – The attempt by user [domain]\[username] to restart/shutdown computer [computername] failed.
  • 1074 – The process [filename].[extension] has initiated the restart of computer [computername] on behalf of user [domain]\[username\ for the
  • 1076 – ???
  • 6008 – The previous system shutdown at [time-in-local-format] on [date-in-local-format] was unexpected.

You can also run this as a batch file, but not you need to escape the pipe | into ^| like this:

PowerShell Get-EventLog System ^| Where-Object {$_.EventID -eq "1074" -or $_.EventID -eq "6008" -or $_.EventID -eq "1076"} ^| ft Machinename, TimeWritten, UserName, EventID, Message -AutoSize -Wrap

If you have PowerShell 3.0 or greater, then you can use the [Archive.is-In operator:

PowerShell Get-EventLog System ^| Where-Object {$_.EventID -in "41", "109", "1074", "6008", "1076"} ^| ft Machinename, TimeWritten, UserName, EventID, Message -AutoSize -Wrap

–jeroen

Posted in Batch-Files, CommandLine, Development, Power User, PowerShell, PowerShell, Scripting, Software Development, Windows | Leave a Comment »

Installing PowerShell Core on macOS and Linux | Microsoft Docs

Posted by jpluimers on 2018/03/26

I forgot to blog about this before, but 2 months ago PowerShell core came available: [WayBack] PowerShell Core 6.0: Generally Available (GA) and Supported! | PowerShell Team Blog.

[WayBack] Installing PowerShell Core on macOS and Linux | Microsoft Docs is easy (one way is through homebrew:

$ brew tap caskroom/cask
$ brew cask install powershell

If you already installed a beta, then the steps are these:

$ brew update
$ brew cask reinstall powershell

Note that after installation, it is known as pwsh (at least one of the betas named it powershell) to set PowerShell Core apart from PowerShell*:

$ pwsh --version
PowerShell v6.0.2

Via: [WayBack] PowerShell Core 6.0 is a new edition of PowerShell that is cross-platform (Windows, macOS, and Linux), open-source, and built for heterogeneous environm… – Lars Fosdal – Google+

*pwsh versus powershell

There has been quite a discussion on the PowerShell Core repository on the rename, but I think it is for a good reason.

Too bad that during part of the beta, the old name powershell was used, but beta-time means things break every now and then.

PowerShell Core is sufficiently different from prior PowerShell versions to warrant a name change. This also makes it a lot easier to use them side-by-side.

Many other names (like posh, pcsh or psh) were considered, usually because of naming conflicts with existing tools (like posh) or easy confusion with existing shells (like pcsh and csh). A benefit on Linux/macOS is that it now ends with sh like virtually all other shells.

More background information is at:

–jeroen

Posted in Apple, CommandLine, Development, Home brew / homebrew, Mac, Mac OS X / OS X / MacOS, MacBook, MacBook Retina, MacBook-Air, MacBook-Pro, MacMini, Power User, PowerShell, PowerShell, Scripting, Software Development | Leave a Comment »

 
%d bloggers like this: