I've been "playing" with some Dell hardware recently and as with everything I like to try and automate as many tasks as possible.
Dell have a really useful tool called Racadm which is a command line utility which you can call from a script to read and write various properties of Dell iDRAC and CMC (Chassis Management Controller).
However, since the latest iDRAC and CMC are built around WSMAN and DMTF standards, I prefer a more PowerShell only approach.
The key PowerShell command for querying is Get-CimInstance. Before we can use this command however we first need to establish a remote CIM Session to the hardware.
This is accomplished by using the New-CimSession and New-CimSessionOption cmdlets.
So...
Use some variables to store the IP, username and password for the iDRAC
$UserName="root"
$Password="calvin"
$DracIP="10.10.0.120"
Convert the username and password into a PS Credential
$SecurePass = ConvertTo-SecureString $Password -AsPlainText -Force
$DracCred = new-object -typename System.Management.Automation.PSCredential -argumentlist $UserName,$SecurePass
We can then create a new CimSessionOption object, which for the Dell Hardware the below works nicely
$cimop=New-CimSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck -Encoding Utf8 -UseSsl
Then using the above variables and new session object we can create a new CIM session to the iDRAC
$Dracsession=New-CimSession -Authentication Basic -Credential $DracCred -ComputerName $DracIP -Port 443 -SessionOption $cimop -OperationTimeoutSec 10000000
Once we have the session established, we can then use the Get-CimInstance cmdlets to query various properties by passing in a WSMAN/WinRM ResourceURI.
For example, if we just wanted to query the general BIOS properties, we could use the following URI: http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/root/dcim/DCIM_SystemView
That would form the following command (cmdlet - session - resourceuri):
Get-CimInstance -CimSession $Dracsession -ResourceUri "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/root/dcim/DCIM_SystemView"
Which supplies information like this:
This way if you assign the object to a variable ($BIOSINFO=Get-CimInst ...) then we can pull out specific items within scripts:
Again, you can do similar things with other hardware properties, for example I can use the resource URI for getting the network card information from a server (http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/root/dcim/DCIM_NICView)
Drop this into a command:
$NICS=Get-CimInstance -CimSession $Dracsession -ResourceUri "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/root/dcim/DCIM_NICView"
... and now we can get the various MAC Addresses of the various NICs
$NICS[0].PermanentMACAddress
$NICS[1].PermanentMACAddress
...
$NICS[6].PermanentMACAddress
$NICS[7].PermanentMACAddress
Hmm... Useful for SCVMM Bare Metal deployment scripting maybe?
The only thing that I struggled with this very simple method of querying the hardware for info, was the resource URI needed.
Well to help with this, the following bits of information from Dell are a god send:
DCIM Profile Library
http://en.community.dell.com/techcenter/systems-management/w/wiki/1906.dcim-library-profile.aspx
WinRM WebServices for Lifecycle Controller
http://en.community.dell.com/techcenter/extras/m/white_papers/20066174.aspx
Next time I'll post about using PowerShell to set the values rather than just query them.
Showing posts with label Scripting. Show all posts
Showing posts with label Scripting. Show all posts
Thursday, 26 September 2013
Monday, 24 June 2013
System Center 2012 R2 Preview - Download and Extract Script
Well, System Center 2012 R2 Preview is here a day earlier than I expected.
Eskor Koneti posted a list of the direct download links to the preview bits here:
http://eskonr.com/2013/06/configmgr-sccm-2012-r2-preview-is-available-for-download/
So I thought I'd wrap them quickly into a PowerShell script that downloads and then extracts all the components ready for install.
I've commented out the DPM download and install as for me it wasn't downloading correctly (either manually or via the script) but feel free to try it.
The script has no error checking and I know could be much smoother, but hey, it's not even 8am here in the UK so what do you expect!
$dwnld = "E:\System_Center_2012_R2"
if (!(Test-Path -path $dwnld))
{
New-Item $dwnld -type directory
}
$object = New-Object Net.WebClient
$SCCMurl = 'http://care.dlservice.microsoft.com/dl/download/evalx/sc2012/SC2012_R2_PREVIEW_SCCM_SCEP.exe'
$object.DownloadFile($SCCMurl, "$dwnld\SC2012_R2_PREVIEW_SCCM_SCEP.EXE")
$object = New-Object Net.WebClient
$SCCMurl = 'http://care.dlservice.microsoft.com/dl/download/evalx/sc2012/SC2012_R2_PREVIEW_SCOM.exe'
$object.DownloadFile($SCCMurl, "$dwnld\SC2012_R2_PREVIEW_SCOM.EXE")
$object = New-Object Net.WebClient
$SCCMurl = 'http://care.dlservice.microsoft.com/dl/download/evalx/sc2012/SC2012_R2_PREVIEW_SCVMM.exe'
$object.DownloadFile($SCCMurl, "$dwnld\SC2012_R2_PREVIEW_SCVMM.EXE")
$object = New-Object Net.WebClient
$SCCMurl = 'http://care.dlservice.microsoft.com/dl/download/evalx/sc2012/SC2012_R2_PREVIEW_SCSM.exe'
$object.DownloadFile($SCCMurl, "$dwnld\SC2012_R2_PREVIEW_SCSM.EXE")
$object = New-Object Net.WebClient
$SCCMurl = 'http://care.dlservice.microsoft.com/dl/download/evalx/sc2012/SC2012_R2_PREVIEW_SCO.exe'
$object.DownloadFile($SCCMurl, "$dwnld\SC2012_R2_PREVIEW_SCO.EXE")
$object = New-Object Net.WebClient
$SCCMurl = 'http://care.dlservice.microsoft.com/dl/download/evalx/sc2012/SC2012_R2_PREVIEW_SCAC.exe'
$object.DownloadFile($SCCMurl, "$dwnld\SC2012_R2_PREVIEW_SCAC.EXE")
#$object = New-Object Net.WebClient
# $SCCMurl = 'http://care.dlservice.microsoft.com/dl/download/evalx/sc2012/SC2012_R2_PREVIEW_SCDPM.exe'
# $object.DownloadFile($SCCMurl, "$dwnld\SC2012_R2_PREVIEW_SCDPM.EXE")
Start-Process -FilePath "$dwnld\SC2012_R2_PREVIEW_SCAC.EXE" -Wait -ArgumentList /DIR="$dwnld\SCAC", /VERYSILENT
#Start-Process -FilePath "$dwnld\SC2012_R2_PREVIEW_SCDPM.EXE" -Wait -ArgumentList /DIR="$dwnld\SCDPM", /VERYSILENT
Start-Process -FilePath "$dwnld\SC2012_R2_PREVIEW_SCO.EXE" -Wait -ArgumentList /DIR="$dwnld\SCO", /VERYSILENT
Start-Process -FilePath "$dwnld\SC2012_R2_PREVIEW_SCOM.EXE" -Wait -ArgumentList /DIR="$dwnld\SCOM", /VERYSILENT
Start-Process -FilePath "$dwnld\SC2012_R2_PREVIEW_SCSM.EXE" -Wait -ArgumentList /DIR="$dwnld\SCSM", /VERYSILENT
Start-Process -FilePath "$dwnld\SC2012_R2_PREVIEW_SCVMM.EXE" -Wait -ArgumentList /DIR="$dwnld\SCVMM", /VERYSILENT
Start-Process -FilePath "$dwnld\SC2012_R2_PREVIEW_SCCM_SCEP.EXE" -Wait -ArgumentList /Auto, "$dwnld\SCCM"
Eskor Koneti posted a list of the direct download links to the preview bits here:
http://eskonr.com/2013/06/configmgr-sccm-2012-r2-preview-is-available-for-download/
So I thought I'd wrap them quickly into a PowerShell script that downloads and then extracts all the components ready for install.
I've commented out the DPM download and install as for me it wasn't downloading correctly (either manually or via the script) but feel free to try it.
The script has no error checking and I know could be much smoother, but hey, it's not even 8am here in the UK so what do you expect!
$dwnld = "E:\System_Center_2012_R2"
if (!(Test-Path -path $dwnld))
{
New-Item $dwnld -type directory
}
$object = New-Object Net.WebClient
$SCCMurl = 'http://care.dlservice.microsoft.com/dl/download/evalx/sc2012/SC2012_R2_PREVIEW_SCCM_SCEP.exe'
$object.DownloadFile($SCCMurl, "$dwnld\SC2012_R2_PREVIEW_SCCM_SCEP.EXE")
$object = New-Object Net.WebClient
$SCCMurl = 'http://care.dlservice.microsoft.com/dl/download/evalx/sc2012/SC2012_R2_PREVIEW_SCOM.exe'
$object.DownloadFile($SCCMurl, "$dwnld\SC2012_R2_PREVIEW_SCOM.EXE")
$object = New-Object Net.WebClient
$SCCMurl = 'http://care.dlservice.microsoft.com/dl/download/evalx/sc2012/SC2012_R2_PREVIEW_SCVMM.exe'
$object.DownloadFile($SCCMurl, "$dwnld\SC2012_R2_PREVIEW_SCVMM.EXE")
$object = New-Object Net.WebClient
$SCCMurl = 'http://care.dlservice.microsoft.com/dl/download/evalx/sc2012/SC2012_R2_PREVIEW_SCSM.exe'
$object.DownloadFile($SCCMurl, "$dwnld\SC2012_R2_PREVIEW_SCSM.EXE")
$object = New-Object Net.WebClient
$SCCMurl = 'http://care.dlservice.microsoft.com/dl/download/evalx/sc2012/SC2012_R2_PREVIEW_SCO.exe'
$object.DownloadFile($SCCMurl, "$dwnld\SC2012_R2_PREVIEW_SCO.EXE")
$object = New-Object Net.WebClient
$SCCMurl = 'http://care.dlservice.microsoft.com/dl/download/evalx/sc2012/SC2012_R2_PREVIEW_SCAC.exe'
$object.DownloadFile($SCCMurl, "$dwnld\SC2012_R2_PREVIEW_SCAC.EXE")
#$object = New-Object Net.WebClient
# $SCCMurl = 'http://care.dlservice.microsoft.com/dl/download/evalx/sc2012/SC2012_R2_PREVIEW_SCDPM.exe'
# $object.DownloadFile($SCCMurl, "$dwnld\SC2012_R2_PREVIEW_SCDPM.EXE")
Start-Process -FilePath "$dwnld\SC2012_R2_PREVIEW_SCAC.EXE" -Wait -ArgumentList /DIR="$dwnld\SCAC", /VERYSILENT
#Start-Process -FilePath "$dwnld\SC2012_R2_PREVIEW_SCDPM.EXE" -Wait -ArgumentList /DIR="$dwnld\SCDPM", /VERYSILENT
Start-Process -FilePath "$dwnld\SC2012_R2_PREVIEW_SCO.EXE" -Wait -ArgumentList /DIR="$dwnld\SCO", /VERYSILENT
Start-Process -FilePath "$dwnld\SC2012_R2_PREVIEW_SCOM.EXE" -Wait -ArgumentList /DIR="$dwnld\SCOM", /VERYSILENT
Start-Process -FilePath "$dwnld\SC2012_R2_PREVIEW_SCSM.EXE" -Wait -ArgumentList /DIR="$dwnld\SCSM", /VERYSILENT
Start-Process -FilePath "$dwnld\SC2012_R2_PREVIEW_SCVMM.EXE" -Wait -ArgumentList /DIR="$dwnld\SCVMM", /VERYSILENT
Start-Process -FilePath "$dwnld\SC2012_R2_PREVIEW_SCCM_SCEP.EXE" -Wait -ArgumentList /Auto, "$dwnld\SCCM"
Labels:
2012,
Demo,
Download,
Eval,
Evaluation,
PowerShell,
Preview,
R2,
Scripting,
System Center
Monday, 5 March 2012
Service Manager - Bulk change the priority (Impact & Urgency)
A customer had the requirement the other day to bulk change the priority on a certain classification of Incidents (They were using incidents of a certain classification in place of Service Requests)
I ran into a problem getting Orchestrator connected to SCSM, so it was time for a quick PowerShell script.
Import-Module SMLETS
$IRClass = Get-SCSMClass -Name System.WorkItem.Incident$
$EnumClass = Get-SCSMEnumeration | Where-Object{$_.displayname -eq 'Other Problems'}
$IRs = Get-SCSMObject -Class $IRClass |Where-Object{$_.Classification -eq $EnumClass}
$PropertyHashTable = @{"Impact" = "Low"}
$IRs | Set-SCSMObject -PropertyHashtable $PropertyHashTable
$PropertyHashTable = @{"Urgency" = "Low"}
$IRs | Set-SCSMObject -PropertyHashtable $PropertyHashTable
This basically finds all incidents of classification 'Other Problems' (just as an example!) and then changes the impact and urgency to low, therefore putting the priority to the lowest possible value.
I ran into a problem getting Orchestrator connected to SCSM, so it was time for a quick PowerShell script.
Import-Module SMLETS
$IRClass = Get-SCSMClass -Name System.WorkItem.Incident$
$EnumClass = Get-SCSMEnumeration | Where-Object{$_.displayname -eq 'Other Problems'}
$IRs = Get-SCSMObject -Class $IRClass |Where-Object{$_.Classification -eq $EnumClass}
$PropertyHashTable = @{"Impact" = "Low"}
$IRs | Set-SCSMObject -PropertyHashtable $PropertyHashTable
$PropertyHashTable = @{"Urgency" = "Low"}
$IRs | Set-SCSMObject -PropertyHashtable $PropertyHashTable
This basically finds all incidents of classification 'Other Problems' (just as an example!) and then changes the impact and urgency to low, therefore putting the priority to the lowest possible value.
Disclaimer: This script is provided as is, with no warranties, expressed or implied and has only been tested within my test environment.
Thursday, 1 March 2012
SCOM DMZ/Workgroup Agent Deployment Script(s)
I've been working for a customer tidying up their System Center installation this week and as part of that I was showing them how to deploy OpsMgr agents to their DMZ.
Their DMZ consists of workgroup based servers, which means each one needed certificates generating, installing and associating in order to work.
I was bored after doing the first one as it was so tedious so I took the time to write a couple of scripts to automate the process as much as possible.
So, script #1:
1.DMZAgentInstall.cmd
Running this script on the DMZ server will...
So, script #2:
2.CreateCertificate.cmd
This script must be run on a domain computer than has access to the issuing certificate server and run using an account that has the auto enrolment rights on the certificate.
Now a couple of things:
Rename the downloaded files from .txt to .cmd
Share the agent management folder on the RMS
Create a Certs folder in the agent management folder on the RMS
Change the following highlighted variables to reflect your environment
The script assumes you're using a PKI environment with the SCOM Certificate Template setup ready
** Certificate Server Variables **
SET CERTPATH=\\<<SERVERNAME>>\<<SHARENAME>>\Certs
SET CATEMPLATE=<<SCOMGatewayAuthenticationTemplateName>>
SET CAFQDN=<<SERVERFQDN>>
SET CASERVER=<<CASERVER>>
** OpsMgr Agent Variables **
SET SOURCEFILES=\\<<SERVERNAME>>\<<SHARENAME>>
SET MGTGRP=<<SCOMMGTGRP>>
SET MGTSVRDNS=<<SERVERFQDN>>
SET SECPORT=5723
Scripts to Download:
Their DMZ consists of workgroup based servers, which means each one needed certificates generating, installing and associating in order to work.
I was bored after doing the first one as it was so tedious so I took the time to write a couple of scripts to automate the process as much as possible.
So, script #1:
1.DMZAgentInstall.cmd
Running this script on the DMZ server will...
- Prompt for the name to be used for the certificate (preferably FQDN, but make sure it matches the full computer name)
- Create the certificate request file
- Upload the certificate request file to a folder on the RMS
- Pause for the "2.GenerateCertificate.cmd" script to be run on a server/workstation on the same domain as the certificate server
- Imports the Root CA certificate chain
- Imports the SCOM Agent Certificate
- Copies the agent install files locally (Doesn't have to be done but did in this environment due to IE7 stopping files being executed from a remote share)
- Installs the agent
- Installs the CU5 updates
- Runs MOMCertImport to associate the certificate to the Health Service
- Restarts the Health Service
So, script #2:
2.CreateCertificate.cmd
This script must be run on a domain computer than has access to the issuing certificate server and run using an account that has the auto enrolment rights on the certificate.
- Prompts for the full server name used during the 1.DMZAgentInstall.cmd script
- Submits the certificate request file to the certificate server
- Retrieves the certificate and stores it ready for import
Now a couple of things:
- I know this would have been better in PowerShell before someone says it, but the customer had mainly Windows 2003 Servers, without PowerShell installed.
- If you have access to the certificate server from the DMZ, you could probably streamline this to one script, but this customer didn't.
- This was a quick and dirty throw together, feel free to improve and post back the results ;)
Rename the downloaded files from .txt to .cmd
Share the agent management folder on the RMS
Create a Certs folder in the agent management folder on the RMS
Change the following highlighted variables to reflect your environment
The script assumes you're using a PKI environment with the SCOM Certificate Template setup ready
** Certificate Server Variables **
SET CERTPATH=\\<<SERVERNAME>>\<<SHARENAME>>\Certs
SET CATEMPLATE=<<SCOMGatewayAuthenticationTemplateName>>
SET CAFQDN=<<SERVERFQDN>>
SET CASERVER=<<CASERVER>>
** OpsMgr Agent Variables **
SET SOURCEFILES=\\<<SERVERNAME>>\<<SHARENAME>>
SET MGTGRP=<<SCOMMGTGRP>>
SET MGTSVRDNS=<<SERVERFQDN>>
SET SECPORT=5723
Scripts to Download:
Friday, 1 July 2011
Scripted Install of System Center Orchestrator Beta and all pre-reqs
There's been a few posts floating around now showing how to do a standard setup of the new System Center Orchestrator Beta (SCORCH) so I thought rather than doing yet another that it was time to do something different.
So I thought it might be a good idea to try automating the installation of SCORCH, which is rather fitting for an automation product.
So I wrote a quick powershell script that not only silently installs SCORCH, but will also setup a fresh built server with all required pre-reqs, SQL, create a service account and setup necessary rights for it.
I also thought I'd get it all on video as well!
So there you have it, an easy, repeatable, automated method of setting up a quick Orchestrator test server.
So I thought it might be a good idea to try automating the installation of SCORCH, which is rather fitting for an automation product.
So I wrote a quick powershell script that not only silently installs SCORCH, but will also setup a fresh built server with all required pre-reqs, SQL, create a service account and setup necessary rights for it.
I also thought I'd get it all on video as well!
Basically the script will go through and install/setup in this order:
.Net Framework 3.5
.Net Framework 4.0
Silverlight
Required IIS Role & Features
(Web-Common-Http,Web-Static-Content,Web-Default-Doc,Web-Dir-Browsing,Web-Http-Errors,Web-Http-Logging,Web-Request-Monitor,Web-Stat-Compression)
SQL 2008 R2
Create a Local Service account called SCORCH_SA
Add it to the local admin group
Assign it logon as a service rights (using ntrights.exe from the 2003 resource kit)
The script then silently installs Orchestrator, with all components.
This is achieved using the following command:
setup.exe /Silent /ServiceUserName:$UserName /ServicePassword:$Password /Components:All /DbServer:$ComputerName /DbNameNew:Orchestrator /ScoAdmin:$ComputerName\Administrators /WebServicePort:81 /WebConsolePort:82
where you see a $ prefix that's where a variable is passed from the script to the command line, normally these would be manually typed as username, server, password etc
During the CEP kickoff meeting it was mentioned that an install of SCORCH and an import of a policy on a server with the pre-reqs installed had been done in 5 minutes, and a mini challenge laid down to see if it could be done quicker.... once the pre-reqs were installed, my script let me install and import in about 3 minutes!!
You can find the link to the powershell script here:
If you want to try this yourself then you'll need to add NTRights.exe from the 2003 reskit, .Net4.0 full framework, silverlight and the PS script to the SCORCH extracted folder and have the SQL disk in Drive D (or modify the script)
Monday, 28 March 2011
Automatically Merge SCCM Conflicting Records
A colleague of mine has just blogged about this useful script he found the other day to help automatically merge ConfigMgr conflicting records when your site isn't in Native Mode.
http://ixrv.blogspot.com/2011/03/automatically-merge-sccm-conflicting.html
http://ixrv.blogspot.com/2011/03/automatically-merge-sccm-conflicting.html
Wednesday, 21 July 2010
Pinning Icons to the Windows 7 Taskbar
The Deployment Guys posted an article a couple of months back on how to script pinning shortcuts to the Windows 7 Taskbar.
http://blogs.technet.com/deploymentguys/archive/2009/04/08/pin-items-to-the-start-menu-or-windows-7-taskbar-via-script.aspx
However, the scripting method won't work during an SCCM OSD deployment as the task sequence runs in the Local System context which has no shell access and the script depends on the Explorer shell because it is executing shell verbs.
So, there's another way:
You can copy icons to the C:\Users\Default\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar folder if you want to make them available to all profiles created AFTER you've copied icons into it.
This is handy I find when creating images as it allows for quick customisations to the taksbar that will affect all users loging onto the machine after it's had the image deployed to it and can easily be added as a "Run Command Line" task in an SCCM OSD Task Sequence.
If the folder doesn't exist (Doesn't by default if I remember correctly) then just create it. I also then set it to hidden like it is in a normal user profile, but I'm just a neat freak :P
Also, if you use a reference computer to set the icons in the order that you require, exporting the data from this registry key: [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband] will then allow you to re-import it into the default users profile to affect the icon order for all your users.
http://blogs.technet.com/deploymentguys/archive/2009/04/08/pin-items-to-the-start-menu-or-windows-7-taskbar-via-script.aspx
However, the scripting method won't work during an SCCM OSD deployment as the task sequence runs in the Local System context which has no shell access and the script depends on the Explorer shell because it is executing shell verbs.
So, there's another way:
You can copy icons to the C:\Users\Default\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar folder if you want to make them available to all profiles created AFTER you've copied icons into it.
This is handy I find when creating images as it allows for quick customisations to the taksbar that will affect all users loging onto the machine after it's had the image deployed to it and can easily be added as a "Run Command Line" task in an SCCM OSD Task Sequence.
If the folder doesn't exist (Doesn't by default if I remember correctly) then just create it. I also then set it to hidden like it is in a normal user profile, but I'm just a neat freak :P
Also, if you use a reference computer to set the icons in the order that you require, exporting the data from this registry key: [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband] will then allow you to re-import it into the default users profile to affect the icon order for all your users.
Subscribe to:
Posts (Atom)