header image

Archive for February, 2019

PowerShell interviews

Posted by: | February 28, 2019 Comments Off on PowerShell interviews |

Following my last post about sample questions for PowerShell interviews that I’d stumbled across I’ve been asked what sort of questions I’d ask – given my statement that many of the question sets were out of date.   I’ve thought about it and decided I’ll run an occasional series of questions and the information I’d […]

under: PowerShell

PowerShell interview questions

Posted by: | February 27, 2019 Comments Off on PowerShell interview questions |

For some bizarre reason I ended up looking at various sets of PowerShell interview questions and answers.   For the most part they scared me – due to their outdated nature.   Many, if not most, of the question sets hadn’t been brought up to date for PowerShell v5.1 and very few even mentioned v6.x. […]

under: PowerShell

Execution policy

Posted by: | February 26, 2019 Comments Off on Execution policy |

PowerShell gives you a number of options regarding execution policy. You use one of the following options with Set-Execution policy: Restricted – won’t run scripts or profiles. This is the default execution policy Allsigned – only scripts (and profiles) signed with a trusted certificate can run. This includes anything you create on local machine. RemoteSigned […]

under: PowerShell

Processing files with switch

Posted by: | February 25, 2019 Comments Off on Processing files with switch |

The switch statement has a –file parameter that can be used to give the path to a file. The file is read one line at a time and processed through the switch statement. The example from last time can be used to demonstrate processing files with switch.   $fnum = 1 switch -file C:\test\Data.txt { […]

under: PowerShell

Splitting a file

Posted by: | February 25, 2019 Comments Off on Splitting a file |

Saw a question about splitting a file that had repeating data blocks. Each block starts with HOST so the code to split becomes: $fnum = 1 Get-Content -Path C:\test\Data.txt | ForEach-Object -Process { if ($_ -like ‘HOST*’) { $file = “C:\test\outdata{0:00}.txt” -f $fnum $fnum ++ } Add-Content -Path $file -Value $_ }   Initialise a […]

under: PowerShell

PowerShell operators

Posted by: | February 24, 2019 Comments Off on PowerShell operators |

PowerShell has operators – lots of operators. This is a quick overview of the PowerShell Operators. The obvious place to start is the arithmetic operators – see about_Arithmetic_Operators +, –, *, / perform the four arithmetic operations % is for modular arithmetic – get the remainder after division -shl and –shr perform shift left and […]

under: PowerShell

Summing multiples

Posted by: | February 22, 2019 Comments Off on Summing multiples |

Came across the project Euler web site – https://projecteuler.net. It has literally hundreds of problems – mainly mathematical – that’ll illustrate some useful PowerShell techniques. The first problem is summing multiples.   You need to sum all of the multiples of 3 or 5 below 1000.   The first thing to do is to read the problem very […]

under: PowerShell

The source of PowerShell cmdlets

Posted by: | February 21, 2019 Comments Off on The source of PowerShell cmdlets |

The source of PowerShell cmdlets seems to cause a lot of confusion. The first point is that the PowerShell team, and now the open source project, are only responsible for the PowerShell engine and the core modules – basically most of what you’ll find in C:\Program Files\PowerShell\6\Modules\ CimCmdlets Microsoft.PowerShell.Archive Microsoft.PowerShell.Diagnostics Microsoft.PowerShell.Host Microsoft.PowerShell.Management Microsoft.PowerShell.Security Microsoft.PowerShell.Utility Microsoft.WSMan.Management […]

under: PowerShell

PowerShell v6.1.3 install problem

Posted by: | February 19, 2019 Comments Off on PowerShell v6.1.3 install problem |

PowerShell v6.1.3 install problem prevented my from changing the working directory.   The introduction of the –WorkingDirectory parameter pwsh.exe has caused problems – usually forcing PowerShell to ignore any directives in your profile to set a working folder.   In previous versions this was overcome by changing the –WorkingDirectory parameter on the icon. This only […]

under: PowerShell v6

PowerShell v6.1.3

Posted by: | February 19, 2019 Comments Off on PowerShell v6.1.3 |

PowerShell v6.1.3 has been released – https://github.com/PowerShell/PowerShell/releases It primarily fixes the security issues from CVE-2019-0627 CVE-2019-0631 CVE-2019-0632   which are to do with User Mode Code Integrity policy bypasses and CVE-2019-0657   which is to do with domain spoofing   I expect the fixes to appear in the next release of v6.2 preview

under: PowerShell v6

Older Posts »