Monday, February 2, 2015

PowerShell Version versus Operation System

Windows

 

XP SP2

XP SP3

Vista

Vista SP1

7

7 SP1

8

8.1

10

1.0

X

 

X

           

2.0

 

X

 

   X

X

       

3.0

         

X

X

   

4.0

             

X

 

5.0

             

O

X

X – Installed
O – Optional

Windows Server

 

2003

2008

2008  SP1

2008 R2

2012

2012 R2

2016

1.0

X

O

         

2.0

     

X

     

3.0

   

X

X

X

   

4.0

         

X

 

5.0

         

O

X

X – Installed
O – Optional

Reference

https://msdn.microsoft.com/en-us/powershell/scripting/setup/windows-powershell-system-requirements

https://4sysops.com/archives/powershell-versions-and-their-windows-version/

Wednesday, December 17, 2014

Parsing Log File with PowerShell

Interesting article

http://matthewyarlett.blogspot.co.uk/2014/11/quick-and-dirty-parsing-logs-with.html

here is the code for reference

# Set the path to the log files            
$path = "C:\Temp\Logs"
# Get a collection of all the log files (anything ending in .log)
$files = Get-ChildItem -Path $path -Filter "*.log"
# Pipe the collection of log files to the ForEach-Object cmdlet
# (the alias of ForEach-Object is %)
$files | %{
# Call the OpenText method, to return a System.IO.StreamReader object
$file = $_.OpenText();
# Record the current line number (to use in the console output)
$lineNum = 1;
Write-Host "Checking file"$_.Name -f Yellow;
# Use the EndOfStream method (which returns true when you have reach the end
# of the file), read each line of the file.
while($file.EndOfStream -ne $true)
{
# Read the next line in the file
$line = $file.ReadLine();
if($line -ne $null)
{
# Use the String ToLower and Contains methods to check for occurances
# of the strings (or values) you need to check the file for
# In this example, I'm looking for any instances of the text "error" or "exception"
if($line.ToLower().Contains("error") -or $line.ToLower().Contains("exception"))
{
# If the current lines contains a match, write the line number
# and line text out to the console
Write-Host "Line: $lineNum " -NoNewline -ForegroundColor Green;
Write-Host $line -f Red;
}
}
# Increment the line number
$lineNum++;
}
}

Wednesday, July 2, 2014

ISE–PowerShell Integrated Scripting Environment

Here is some fun with the Windows PowerShell Integrated Scripting Environment or ISE

Start ISE

simply type ise

Start ISE as administrator

start-process PowerShell_ISE –verb RunAs

Customize ISE for SharePoint

http://thecloudengineer.blogspot.com/2011/10/create-ise-enabled-for-sharepoint.html

Configuring the PowerShell ISE for use with Git and GitHub


http://mikefrobbins.com/2016/02/09/configuring-the-powershell-ise-for-use-with-git-and-github/

Tuesday, December 3, 2013

Remove PowerShell Object

 

I was working with SharePoint and found an object that I needed to delete

image

NOTE that lega… is the friendly name.  Well not really.  On close examination appears that the name was corrupt.  The name was lega … with more info.

image

So using a where-object I gathered a couple of objects and saved as an array.

image

Then deleted the first object in the array using the name property.

image

HTH