Tuesday, May 12, 2015

PowerShell Tip: #1 – PowerShell Demo Scripts

Use ISE to make building your scripts easier.  You can run the script line by line or the entire script by using the F5 and F8 keys to help run your scripts.  If you don’t like the built-in ISE from your OS you can use a free add-on from Idera called PowerShell Plus.

https://www.idera.com/productssolutions/freetools/powershellplus

But during demos you can accidently hit he wrong key, that is run the entire script that kills the demo.  So make sure to include a break at the top of the script

break

Thank you Ashley http://blogs.technet.com/b/ashleymcglone/

Wednesday, April 15, 2015

Active Directory PowerShell

Great question: Can I Create Active Directory Users Based On Excel Input

https://gallery.technet.microsoft.com/scriptcenter/PowerShell-Create-Active-7e6a3978

Great question:  How do I find all the attributes of my users in the Active Directory

First start by starting the Active Directory Module for Windows PowerShell

SNAGHTMLabcee102

Get-ADUser -filter *
image 

Problem is however if you get all the users using -filter * you are missing some attributes. So using a wildcard for the properties will return all.

image 
Using OGV (Out-Gridview) you get a quick view report





Get-ADUser -filter * -properties * | ogv




image



NOTE: You can use the same format above for ad users, ad groups or ad computers

Get-ADComputerUser -filter * -properties * | ogv

Get-ADGroup -filter * -properties * | ogv

Get-ADUser -filter * -properties * | ogv




SNAGHTMLabdebe56



Hope that Helps, Happy PowerShelling

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/