Archive for the ‘Technology’ Category

 

Hi All,

It has been a really busy time for me. However, I am very happy with life at the moment. Just recently I received a “Microsoft Community Contributor” award from Microsoft.

MCC_Logo_NEW

I know I have been a little quite the last little while. I have been busy doing a job that everyone loves (I wish there was a font for sarcasm). I have been VERY busy documenting my production environment including Hyper-V, Active Directory and Exchange. This is a long and tiresome process, however PowerShell has been a phenomenal help and I thought I would share a few bits of code from PowerShell that have made my life a little easier in this process.

ACTIVE DIRECTORY

A script to list all GPO in required Domain

Import-Module grouppolicy
#command to get all GPOS
get-gpo -all -Domain domainname

A script to backup all GPOs for said domain

Import-Module grouppolicy
#command to backup all GPOS
Backup-GPO -All -Domain domainname -Path filepath

EXCHANGE 

A script to pull the IP address listed within a Receive Connector

Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Support
Get-ReceiveConnector -Server <nameoripofHTServer>
Get-ReceiveConnector -Identity "<name of identity>" | Select-Object -ExpandProperty RemoteIPRanges

VIRTUAL MACHINE MANAGER

A script to pull the VMs being controlled by Virtual Machine manager and sort them by Host Name for easier documentation.

Add-PSSnapin Microsoft.SystemCenter.VirtualMachineManager
Get-VMMServer nameofvmmserver
Get-VM -VMMServer nameofvmmserver | Select-Object -Property Name, Owner, Description, HostName, OperatingSystem, CPUCount, Memory | Sort-Object -Property HostName

Really hope this helps some other people as well.

Follow me

facebook-small3222 twitter-small3222

MCC_Logo_NEW

Advertisements

 

So, just recently I was asked to work yet another miracle.

The Scope.

1. We need to go paperless.

2. We need to move a certain form to an online platform and make it easy for users to fill in. With a custom picture and add checkboxes on top of that.

3. We need this information to be saved onto a SharePoint site with unique filenames.

4. We need this to be simply and NOT require a user to use the traditional “Save As” or “Save to SharePoint”

So away I went and started to think. A few glitches, Point #2, a picture as in the background with control boxes over it. Um……

So, I managed to work around that with playing with the image size and using it as a “Watermark”. One sneaky little thing done, a few more to go. Then I went about adding all my controls for specific entries.

So, now onto the save to SharePoint with unique names. Enter a little bit of VBA coding and lots of Uncle Google. I was able to create a mapped drive in VBA, as you cannot save directly to SharePoint Sad smile. So, map a drive to the folder that can exposed via SharePoint, when you select “Explorer View”. I was then able to use VBA to read information from a TextBox to create the file name. Once that was completed, I remove the drive so that our End Users do not log calls about a new “Mapped drive”. Some of the coding below to help anyone else trying to do something similar.

VBA Code Below

=============

Private Sub CommandButton1_Click()
Set WshNetwork = CreateObject("WScript.Network")
WshNetwork.MapNetworkDrive "Z:", \\sharepointserver@portnumber\DavWWWRoot\libraryname
Set WshNetwork = Nothing
Dim sFileName As String
Dim sPath As String
sFileName = ControlName.Text
sPath = "z:\"
‘(Replace with the name of the formfield you want to use)
ActiveDocument.SaveAs FileName:=sPath & sFileName, FileFormat:=wdFormatDocument
Set WshNetwork = CreateObject("WScript.Network")
WshNetwork.RemoveNetworkDrive "Z:", True
End Sub

Hope this helps someone else.

Follow me

facebook-small32222 twitter-small32222

Hi All,

I have taken the get-hotfix and tweaked it so something useful for my environment.

I have uploaded the .ps1 file to Technet.

My script can be found here

#building options for computer names
Write-host "How do you want to enter computer names?"
Write-host "1 = File with Comnputer names?"
Write-host "2 = Enter manually?"
Write-host ""
$choices1 = Read-host "Enter your choice"

switch ($choices1)
{
    1
        {
            $computernamefile = Read-host "Please enter file path"
            
            $computernames = (Get-Content -Path $computernamefile)
        }
    2
        {
            $computernames = (Read-Host "Enter the Computer Name(s) (separate with a comma)").split(',') | %{$_.trim()}
        }
    default
        {
            Write-Host "Invalid selection"
            Write-Host "Assuming you want to enter manually"
            $computernames = (Read-Host "Enter the Computer Name(s) (separate with a comma)").split(',') | %{$_.trim()}
        }
}

#get username
$cred = $host.ui.PromptForCredential("Need credentials", "Please enter your user name and password.", "", "NetBiosUserName")


#building in choices
write-host ""
Write-Host "======================================"
Write-Host "What type of fix are you looking for?"
Write-host "1 = Hotfix"
Write-host "2 = Security update"
Write-host "3 = Update"
Write-host "4 = Service Pack"
Write-host "5 = All"
Write-host "======================================"
Write-host ""
$choice = Read-host "Please enter choice"

#building html style
$htmlstyle = "<style>"
$htmlstyle = $htmlstyle + "BODY{background-color:Green;}"
$htmlstyle = $htmlstyle + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
$htmlstyle = $htmlstyle + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:GreenYellow}"
$htmlstyle = $htmlstyle + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:palegoldenrod}"
$htmlstyle = $htmlstyle + "</style>"

#buillding folder path
$dir = $env:userprofile
$date = ((Get-Date).toString('yyyMMdd'))

#creating email addresses for recipeint
$recipeint = $env:username
$recipeint = $recipeint + "@europcar.co.za"
$recipeint

#creating email addresses for sender
$sender = $env:username
$sender = $sender + "@europcar.co.za"
$sender

#get-hotfixes
switch ($choice)
{
    1 
        {
            foreach ($computername in $computernames)
            {
                $filenamehtml = "hotfixes.html"
                $filenametxt = "hotfixes.txt"
                $newfolderpath = $dir.tostring() + "\" +$date + "\" + $computername + "\"
                New-Item -ItemType Directory -Path $newfolderpath -ErrorAction "SilentlyContinue"
                $filepathtxt = $dir.tostring() + "\" +$date + "\" + $computername + "\" + $filenametxt
                $filepathhtml = $dir.tostring() + "\" +$date + "\" + $computername + "\" + $filenamehtml
                $description = "Hotfix"
                Write-Host "Gathering Information for $computername" -ForegroundColor green
                $hotfix = Get-HotFix -ComputerName $computername -Description $description -Credential $cred | Sort-Object -Property Description
                $hotfixtxt = Get-HotFix -ComputerName $computername -Description $description -Credential $cred | Sort-Object -Property Description | Out-File -FilePath $filepathtxt
                $hotfixhtml = Get-HotFix -ComputerName $computername -Description $description -Credential $cred | Sort-Object -Property Description | ConvertTo-Html -Property CSName,Description,HotFixID,InstalledBy,InstalledOn -Head $htmlstyle -Body "<H2>Installed $description on $computername</H2>" | out-file -FilePath $filepathhtml
                Write-host "The count of all installed Hotfixes on $computername is:" $hotfix.count
                $hotfix
                write-host ""
                Write-host "Files have been saved to" $newfolderpath
                Write-Host ""
                Write-Host "Sending Mail message to $recipeint" -ForegroundColor blue
                Send-MailMessage -to $recipeint -From $sender -Subject "Installed $description on $computername" -Body "Installed $description on $computername" -Attachments $filepathtxt,$filepathhtml -SmtpServer 172.21.195.31
                
            }
        }
    2 
        {
            foreach ($computername in $computernames)
            {
                $filenamehtml = "securityupdates.html"
                $filenametxt = "securityupdates.txt"
                $newfolderpath = $dir.tostring() + "\" +$date + "\" + $computername + "\"
                New-Item -ItemType Directory -Path $newfolderpath -ErrorAction "SilentlyContinue"
                $filepathtxt = $dir.tostring() + "\" +$date + "\" + $computername + "\" + $filenametxt
                $filepathhtml = $dir.tostring() + "\" +$date + "\" + $computername + "\" + $filenamehtml
                $description = "Security Update"
                Write-Host "Gathering Information for $computername" -ForegroundColor green
                $securityupdate = Get-HotFix -ComputerName $computername -Description $description -Credential $cred | Sort-Object -Property Description
                $securityupdatetxt = Get-HotFix -ComputerName $computername -Description $description -Credential $cred | Sort-Object -Property Description | Out-File -FilePath $filepathtxt
                $securityupdatehtml = Get-HotFix -ComputerName $computername -Description $description -Credential $cred | Sort-Object -Property Description | ConvertTo-Html -Property CSName,Description,HotFixID,InstalledBy,InstalledOn -Head $htmlstyle -Body "<H2>Installed $description on $computername</H2>" | out-file -FilePath $filepathhtml
                Write-host "The count of all installed Service Packs on $computername is:" $securityupdate.count
                $securityupdate
                write-host ""
                Write-host "Files have been saved to" $newfolderpath
                Write-Host ""
                Write-Host "Sending Mail message to $recipeint" -ForegroundColor blue
                Send-MailMessage -to $recipeint -From $sender -Subject "Installed $description on $computername" -Body "Installed $description on $computername" -Attachments $filepathtxt,$filepathhtml -SmtpServer 172.21.195.31
            }
        }
    3 
        {
            foreach ($computername in $computernames)
            {
                $filenamehtml = "updates.html"
                $filenametxt = "updates.txt"
                $newfolderpath = $dir.tostring() + "\" +$date + "\" + $computername + "\"
                New-Item -ItemType Directory -Path $newfolderpath -ErrorAction "SilentlyContinue"
                $filepathtxt = $dir.tostring() + "\" +$date + "\" + $computername + "\" + $filenametxt
                $filepathhtml = $dir.tostring() + "\" +$date + "\" + $computername + "\" + $filenamehtml
                $description = "Update"
                Write-Host "Gathering Information for $computername" -ForegroundColor green
                $update = Get-HotFix -ComputerName $computername -Description $description -Credential $cred | Sort-Object -Property Description
                $updatetxt = Get-HotFix -ComputerName $computername -Description $description -Credential $cred | Sort-Object -Property Description | Out-File -FilePath $filepathtxt
                $updatehtml = Get-HotFix -ComputerName $computername -Description $description -Credential $cred | Sort-Object -Property Description | ConvertTo-Html -Property CSName,Description,HotFixID,InstalledBy,InstalledOn -Head $htmlstyle -Body "<H2>Installed $description on $computername</H2>" | out-file -FilePath $filepathhtml
                Write-host "The count of all installed Service Packs on $computername is:" $update.count
                $update
                write-host ""
                Write-host "Files have been saved to" $newfolderpath
                Write-Host ""
                Write-Host "Sending Mail message to $recipeint" -ForegroundColor blue
                Send-MailMessage -to $recipeint -From $sender -Subject "Installed $description on $computername" -Body "Installed $description on $computername" -Attachments $filepathtxt,$filepathhtml -SmtpServer 172.21.195.31
            }
        }
    4 
        {
            foreach ($computername in $computernames)
            {
                $filenamehtml = "servicepack.html"
                $filenametxt = "servicepack.txt"
                $newfolderpath = $dir.tostring() + "\" +$date + "\" + $computername + "\"
                New-Item -ItemType Directory -Path $newfolderpath -ErrorAction "SilentlyContinue"
                $filepathtxt = $dir.tostring() + "\" +$date + "\" + $computername + "\" + $filenametxt
                $filepathhtml = $dir.tostring() + "\" +$date + "\" + $computername + "\" + $filenamehtml
                $description = "Service Pack"
                Write-Host "Gathering Information for $computername" -ForegroundColor green
                $servicepack = Get-HotFix -ComputerName $computername -Description $description -Credential $cred | Sort-Object -Property Description
                $servicepacktxt = Get-HotFix -ComputerName $computername -Description $description -Credential $cred | Sort-Object -Property Description | Out-File -FilePath $filepathtxt
                $servicepackhtml = Get-HotFix -ComputerName $computername -Description $description -Credential $cred | Sort-Object -Property Description | ConvertTo-Html -Property CSName,Description,HotFixID,InstalledBy,InstalledOn -Head $htmlstyle -Body "<H2>Installed $description on $computername</H2>" | out-file -FilePath $filepathhtml
                Write-host "The count of all installed Service Packs on $computername is:" $all.count
                $servicepack
                write-host ""
                Write-host "Files have been saved to" $newfolderpath
                Write-Host ""
                Write-Host "Sending Mail message to $recipeint" -ForegroundColor blue
                Send-MailMessage -to $recipeint -From $sender -Subject "Installed $description on $computername" -Body "Installed $description on $computername" -Attachments $filepathtxt,$filepathhtml -SmtpServer 172.21.195.31
            }
        }
    5 
        {
            foreach ($computername in $computernames)
            {
                $filenamehtml = "all.html"
                $filenametxt = "all.txt"
                $newfolderpath = $dir.tostring() + "\" +$date + "\" + $computername + "\"
                New-Item -ItemType Directory -Path $newfolderpath -ErrorAction "SilentlyContinue"
                $filepathtxt = $dir.tostring() + "\" +$date + "\" + $computername + "\" + $filenametxt
                $filepathhtml = $dir.tostring() + "\" +$date + "\" + $computername + "\" + $filenamehtml
                Write-Host "Gathering Information for $computername" -ForegroundColor green
                $all = Get-HotFix -ComputerName $computername -Credential $cred | Sort-Object -Property Description
                $alltxt = Get-HotFix -ComputerName $computername -Credential $cred | Sort-Object -Property Description | Out-File -FilePath $filepathtxt
                $allhtml = Get-HotFix -ComputerName $computername -Credential $cred | Sort-Object -Property Description | ConvertTo-Html -Property CSName,Description,HotFixID,InstalledBy,InstalledOn -Head $htmlstyle -Body "<H2>Installed $description on $computername</H2>" | out-file -FilePath $filepathhtml
                Write-host "The count of all installed hotfixes on $computername is:" $all.count
                $all
                write-host ""
                Write-host "Files have been saved to" $newfolderpath
                Write-Host ""
                Write-Host "Sending Mail message to $recipeint" -ForegroundColor blue
                Send-MailMessage -to $recipeint -From $sender -Subject "Installed $description on $computername" -Body "Installed $description on $computername" -Attachments $filepathtxt,$filepathhtml -SmtpServer 172.21.195.31 
            }
        }    
    default 
        {
            foreach ($computername in $computernames)
            {
                $filenamehtml = "all.html"
                $filenametxt = "all.txt"
                $newfolderpath = $dir.tostring() + "\" +$date + "\" + $computername + "\"
                New-Item -ItemType Directory -Path $newfolderpath -ErrorAction "SilentlyContinue"
                $filepathtxt = $dir.tostring() + "\" +$date + "\" + $computername + "\" + $filenametxt
                $filepathhtml = $dir.tostring() + "\" +$date + "\" + $computername + "\" + $filenamehtml
                Write-host "Not a valid choice"
                Write-host "Assuming you want all updates"
                Write-Host "Gathering Information for $computername" -ForegroundColor green
                $all = Get-HotFix -ComputerName $computername -Credential $cred | Sort-Object -Property Description
                $alltxt = Get-HotFix -ComputerName $computername -Credential $cred | Sort-Object -Property Description | Out-File -FilePath $filepathtxt
                $allhtml = Get-HotFix -ComputerName $computername -Credential $cred | Sort-Object -Property Description | ConvertTo-Html -Property CSName,Description,HotFixID,InstalledBy,InstalledOn -Head $htmlstyle -Body "<H2>Installed $description on $computername</H2>" | out-file -FilePath $filepathhtml
                Write-host "The count of all installed hotfixes on $computername is:" $all.count
                $all
                write-host ""
                Write-host "Files have been saved to" $newfolderpath
                Write-Host "" 
                Write-Host "Sending Mail message to $recipeint" -ForegroundColor blue
                Send-MailMessage -to $recipeint -From $sender -Subject "Installed $description on $computername" -Body "Installed $description on $computername" -Attachments $filepathtxt,$filepathhtml -SmtpServer 172.21.195.31
            }
        }
}
Write-Host "Press any key to continue ..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")

Hope you find this helpful.

Follow me

facebook-small32222 twitter-small32222

We have had a few failures of the power kind (thanks to the electricity provider in South Africa, who will remain nameless). So we have now had to build in further redundancy to cater for this and for other business needs. There is nothing worse than getting a phone call saying that critical services are unavailable at a CRITICAL time. What a nightmare. So a few plans were set in motion.

FINALLY, I got my request for DFS approved. YAY!!!!

So, the process started. Installing DFS for Windows Server 2008 R2 is really simple and was completed in a couple of minutes, however the fun starts after the install and with the configuration of the replicated folders. The above link covers all aspects of the install and “sub” installs and procedures like configuring a namespace and replicated folders.

There is just one little “gotcha” I came across, when I tried to create the first replicated folder, I configured the replication pair with the “root” folder. When I was running through the wizard I got an error when trying to replicate security permissions. The mistake I was making was to include the “root” folder. Do NOT do this. The solution is simple, create the root DFS namespace and create separate replicated folder pairs for each sub folder and then wait for the replication to occur. Awesome!!!!!!

 

So now, for additional redundancy. we have another 3rd party application which handles printing and we need to keep an empty “folder structure” for this somewhere safe in case of a DR situation. This is a requirement placed on us by the Vendor. So, I like powershell, so I decided to create a powershell script to do this for me and, of course, the reverse of creating the “folder structure”. Scripts are below.

 

Create-FolderStructure.ps1

#Create an array with folder objects
$dirs = get-childitem -Recurse | Where {$_.psIsContainer -eq $true}
 
#get folder full names
$dirs | select fullname  | out-file

 

So, now you have the folder structure, Great!!!!

However now you need to re-create the folder structure. What now?

Of course, I have created a scriptt for that.

Create-Folders.ps1

$dirs = Get-Content –Path <path of file from previous script>

foreach ($dir in $dirs)
{
    New-Item -Path $dir -ItemType Directory

}

Hope this helps,

Follow me

facebook-small3222 twitter-small3222

Have you ever been in a situation where you have either removed or added a new DPM server to your environment?

It happened to me just the other day, I had to “re-think” my DPM design and starting using “Local” to each Data Centre DPM servers to backup my data at each Data Centre. However, this was not the case before this, we were using the same product, but a different strategy. Now I had DPM agents in both datacentres connecting to DPM servers not in the same Data Centre. For Example, I had Server A (Data Centre 1) with a DPM agent from my secondary DPM Server (Data Centre 2) protecting it. So, I went searching and found my answer and it turned out to be amazingly simple thanks to POWERSHELL. DPM has a POWERSHELL management shell (thank goodness) and some built-in scripts for just this (truly amazing). Within 10 minutes I had changed my DPM agents to report to the DPM Servers and began creating protection as needed like SharePoint (see previous post).

To be safe, these are the steps I followed.

1. Remove old agent

2. Install new agent using CMD prompt

3. Ran attach-productionserver.ps1 to re-allocate to new server.

All steps are nicely listed on Microsoft Technet

This was really easy and well worth the investment in time.

On a side, was also made aware of a DPM Hotfix Rollup Package

 

Hopefully this helps someone else as well.

 

Follow me

facebook-small3 twitter-small3

I have finally found some time to look some more into DPM and decided to modify my environment and created some additional PROTECTION GROUPS. I am particularly chuffed as I have not done this before. Make no error, I have used DPM extensively for mailbox recoveries (Execs and other users crying about loosing items), recovering of databases and VHD (see some of my previous posts). So back to my point, the Protection groups were created without any hassle and now I have a dedicated SharePoint Protection Group.

See below, an extract from a script from Scripting Repository, many thanks to it’s author

http://gallery.technet.microsoft.com/scriptcenter/1c9c61ce-688f-4ef0-8d9b-cd93cd703c45

image

I did however run into a few hiccups and have learnt a few amount Smile

There are a few pre-reqs that are needed before the Sharepoint Protection Group can be created.

ConfigureSharePoint.exe must be run on the server were WSS / MOSS is located.

http://technet.microsoft.com/en-us/library/dd441708.aspx

The SharePoint VSS writer must be started and the SQL VSS Writer must be started.

Then, if like me, you had protected the SQL databases separately, these WSS / MOSS databases will need to be removed from the Protection Group.

Then a few pieces are added, see screenshot below.

image

It does not look like much, however if you look at the “Recovery Options”, it will look a little more familiar with a few more familiar databases.

image

Hopefully this helps you

 

Follow me

facebook-small twitter-small

I do not know about everyone else. I am a rather busy admin and quite fond of powershell and scripting. However, I also have a separate admin account for doing my administrative tasks. Now when you are working with multiple systems, all of which have PowerShell consoles, it can become a little bit of a pain opening a console for Exchange 2010, Operations Manager 2010, Virtual Machine Manager and Service Manager to name a few. There are tons of products that now have powershell interfaces. Would it not be great to have ONE SHELL to control them all, with all the PSSnapins and Modules? The answer is of course, YES. This is what I got right thanks to Uncle GOOGLE and a lot a research and a wonderful thing called the Powershell Profile. So using another link I found as a base, I started my mission. I though of all the modules and pssnapins I used and created the shell below.

image

It adds all the Modules and PSSnapins I use on a daily basis, I also copied the same profile.ps1 to my “admin” profile so that the same would happen when using this as my “admin” account. See code snippet below. The first line of code caters for those people like me using PowerGui and the Script-Explorer addon, that took some time for figure out, hope you enjoy Smile (2 different views included to make it easier to use if you so wish)

 
================================================================

import-module Add-on.ScriptExplorer

# Sets APPDATA environment variable if it doesn’t exist
if (! (Test-Path [string]$env:APPDATA) ) {$env:APPDATA = $env:USERPROFILE + "\Application Data"}
 
# Create Powershell Drives
#New-PSDrive -name SCRIPT -psprovider FileSystem -root "\\fileshare\data\IT Department\Team\Scripts"
#New-PSDrive -name VMSCRIPT -psprovider FileSystem -root "\\fileshare2\common\IT Department\Projects\VMWare\Scripts"
#Set-Location VMSCRIPT:
"You are now PowerShell : " + $env:Username
 
# Exchange 2010
if (((Get-PSSnapin -Name "Microsoft.Exchange.Management.PowerShell.E2010" -ErrorAction SilentlyContinue) -eq $null ) -and ((Get-PSSnapin –registered -Name "Microsoft.Exchange.Management.PowerShell.E2010") -ne $null))
{
   Write-Host "Adding Exchange 2010" -ForegroundColor Green
   Add-PSSnapin -name Microsoft.Exchange.Management.PowerShell.E2010
   ."C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1"; "Connect-ExchangeServer -auto"
}
# Virtual Machine Manager
if (((Get-PSSnapin -Name "Microsoft.SystemCenter.VirtualMachineManager" -ErrorAction SilentlyContinue) -eq $null ) -and ((Get-PSSnapin –registered -Name "Microsoft.SystemCenter.VirtualMachineManager") -ne $null))
{
   Write-Host "Adding Virtual Machine Manager" -ForegroundColor Green
   Add-PSSnapin -name Microsoft.SystemCenter.VirtualMachineManager
   #C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -PSConsoleFile "C:\Program Files\Microsoft System Center Virtual Machine Manager 2008 R2\bin\cli.psc1" -NoExit
}

# Quest Active Directory
if (((Get-PSSnapin -Name "Quest.ActiveRoles.ADManagement" -ErrorAction SilentlyContinue) -eq $null ) -and ((Get-PSSnapin –registered -Name "Quest.ActiveRoles.ADManagement") -ne $null))
{
   Write-Host "Adding Quest Active Directory" -ForegroundColor Green
   Add-PSSnapin -name Quest.ActiveRoles.ADManagement
}
#SMCmdletSnapIn
if (((Get-PSSnapin -Name "SMCmdletSnapIn" -ErrorAction SilentlyContinue) -eq $null ) -and ((Get-PSSnapin –registered -Name "SMCmdletSnapIn") -ne $null))
{
   Write-Host "System Centre 2010 Snapin" -ForegroundColor Green
   Add-PSSnapin -name SMCmdletSnapIn
}
# Operations Manager 2007
if (((Get-PSSnapin -Name "Microsoft.EnterpriseManagement.OperationsManager.Client" -ErrorAction SilentlyContinue) -eq $null ) -and ((Get-PSSnapin –registered -Name "Microsoft.EnterpriseManagement.OperationsManager.Client") -ne $null))
{
   Write-Host "Operations Manager 2007 Snapin" -ForegroundColor Green
   Add-PSSnapin -name Microsoft.EnterpriseManagement.OperationsManager.Client
}
# time to import smlets
$exist = $false
foreach ($modulePath in ${env:PSModulePath}.Split(";"))
{
   if ((Test-Path ($modulePath + "Smlets\smlets.Module.dll")) -and !$exist)
   {
   Write-Host "Adding SMLets for SCSM 2010" -ForegroundColor Green
   $exist = $true
   Import-Module smlets
   }

}
#time to import ActiveDirectoryModule
$exist = $false
foreach ($modulePath in ${env:PSModulePath}.Split(";"))
{
   if ((Test-Path ($modulePath + "ActiveDirectory\ActiveDirectoryPowerShellResources.dll")) -and !$exist)
   {
   Write-Host "Adding ActiveDirectory Module" -ForegroundColor Green
   $exist = $true
   Import-Module ActiveDirectory
   }
}
#time to import FailoverClusters Module
$exist = $false
foreach ($modulePath in ${env:PSModulePath}.Split(";"))
{
   if ((Test-Path ($modulePath + "FailoverClusters\Microsoft.FailoverClusters.PowerShell.dll")) -and !$exist)
   {
   Write-Host "Adding Failover Clusters Module" -ForegroundColor Green
   $exist = $true
   Import-Module FailoverClusters
   }
}
#time to import Group Policy Module
$exist = $false
foreach ($modulePath in ${env:PSModulePath}.Split(";"))
{
   if ((Test-Path ($modulePath + "GroupPolicy\GroupPolicy.psd1")) -and !$exist)
   {
   Write-Host "Adding Group Policy Module" -ForegroundColor Green
   $exist = $true
   Import-Module GroupPolicy
   }
}

function prompt
{
    $cwd = (get-location).Path
    $host.UI.RawUI.WindowTitle = "Fletcher’s Shell " + $global:connectedFqdn
    $host.UI.Write("Yellow", $host.UI.RawUI.BackGroundColor, "[PS]")
    " $cwd>"
}

function get-fletchbanner
{
    write-host "`n         Welcome to the Fletch’s Management Shell!`n"   
}

get-fletchbanner
cd\

=============================================================

 

Talking about “admin” accounts, the one BIG thing about Windows 7 is the lack of “Running as another account and elevated”. I also found a solution to this as well.

I really hope this helps everyone, like this has helped me.

 

Follow me

clip_image001 clip_image002 clip_image003