Hi,
I write down some usefull Powershell scipts that I use in SCSM 2012. Mostly they are close to each other in logic, but minor changes returns different results. I recommend you check these and modify according to your needs.
#Closed and resolveddate is null and adding 2 days to resolved date as closeddate
$Incidents = @(Get-SCSMObject -Class (Get-SCSMClass -Name System.WorkItem.Incident$) | Where-Object {$_.Status -like "*Closed" -and $_.ResolvedDate -eq $NULL})
foreach ($Inc in $Incidents)
{
Set-SCSMObject -Property ResolvedDate -Value ($Inc.ClosedDate).AddDays(-2) -SMObject $Inc
}
#Status Closed but no Closeddate inserted, assigning last modified date as closeddate $Inc1 = @(Get-SCSMObject -Class (Get-SCSMClass -Name System.WorkItem.Incident$) | Where-Object {$_.Status -like "*Closed" -and $_.ClosedDate -eq $NULL})
foreach ($Inc in $Inc1)
{
$Inc | set-scsmobject -Property ClosedDate -Value $Inc.LastModified
write-host $Inc.Name $Inc.ClosedDate
}
#Getting the time difference between lastmodified and resolveddate $Last = @(Get-SCSMObject -Class (Get-SCSMClass -Name System.WorkItem.Incident$) | Where-Object {$_.Status -like "*Closed*" -and $_.closedDate -eq $NULL})
foreach ($L in $Last)
{
$fark = ($L.lastmodified-$L.resolvedDate).duration()
write-host $L.Name /created/ $L.createddate /resolved/ $L.resolveddate /saat/ $fark.TotalHours
}
#Status Closed but closeddate is empty, Adding 2 days to Resolveddate as a closeddate value $Incidents = @(Get-SCSMObject -Class (Get-SCSMClass -Name System.WorkItem.Incident$) | Where-Object {$_.Status -like "*Closed" -and $_.closedDate -eq $NULL})
foreach ($Inc in $Incidents)
{
Set-SCSMObject -Property ClosedDate -Value ($Inc.ResolvedDate).AddDays(2) -SMObject $Inc
}
Search
Tuesday, November 26, 2013
Friday, November 22, 2013
Closing resolved incidents automatically in SCSM with Powershell and/or with SCSM tasks
Hi,
Today, I am going to write down the steps and a powershell script I used for closing resolved incidents automatically in SCSM and/or with SCSM tasks. To note, the environment I work on is a SCSM 2012 SP1 on a 2008 R2 SP1 server.
I had a need for closing incidents after sometime when incidents left resolved but not closed by users. Therefore, we agreed on closing resolved incidents after 2 days automatically with SCSM using a Powershell script running as a scheduled task.
If we explain briefly, what we are going to do is;
Import-Module SMLets
$LogFilename = "anypath\yourlogname.log"
$SMDefaultComputer = "SCSM management computer name"
$Date = (get-date)
$DateString = $Date.toString()
$2DaysOld = (get-date).addhours(-48)
$Incidents = @(Get-SCSMObject –Class(get-scsmclass system.workitem.incident$) | where{$_.resolveddate -lt $2DaysOld -and $_.status -like "*resolv*"})
foreach ($Inc in $Incidents)
{Add-Content -Path $LogFilename ($Date.toString() + " - Any description you desire - " + $Inc.ID + " - " + $Inc.Title)
sleep 1
set-SCSMObject –property Status -Value Closed -SMobject $Inc
Set-SCSMObject –property ClosedDate -Value $Date -SMobject $Inc
}
Save your powershell script to anywhere you want, then you can add as a scheduled task into Task Scheduler like below;
Configure and trigger the script for everyday every 1 hour period;
If you want to Add the script as a task into SCSM console;
On the console go to Library-->Tasks section and create new task. Enter name and description, select "Incident" as target class, choose a custom management pack or create a new one.
Move down to command line tab and fill areas as in screenshot;
Now you will be able to see the task on your consoles Tasks Pane on the right side.
I hope this blog will help you getting over the issue.
C u!..
Today, I am going to write down the steps and a powershell script I used for closing resolved incidents automatically in SCSM and/or with SCSM tasks. To note, the environment I work on is a SCSM 2012 SP1 on a 2008 R2 SP1 server.
I had a need for closing incidents after sometime when incidents left resolved but not closed by users. Therefore, we agreed on closing resolved incidents after 2 days automatically with SCSM using a Powershell script running as a scheduled task.
If we explain briefly, what we are going to do is;
- For a later use to use as a task on any console importing SMLets module, log file path and name, SM management computer name,
- Getting the date script run and getting incidents both resolved and resolved date more than 48 hours,
- For each incident filtered closing the incident and inserting the closed date while writing to the log file specified before.
- Preparing a scheduled task for automation of the script.
- If desired adding as a task on console to run manually when desired.
Import-Module SMLets
$LogFilename = "anypath\yourlogname.log"
$SMDefaultComputer = "SCSM management computer name"
$Date = (get-date)
$DateString = $Date.toString()
$2DaysOld = (get-date).addhours(-48)
$Incidents = @(Get-SCSMObject –Class(get-scsmclass system.workitem.incident$) | where{$_.resolveddate -lt $2DaysOld -and $_.status -like "*resolv*"})
foreach ($Inc in $Incidents)
{Add-Content -Path $LogFilename ($Date.toString() + " - Any description you desire - " + $Inc.ID + " - " + $Inc.Title)
sleep 1
set-SCSMObject –property Status -Value Closed -SMobject $Inc
Set-SCSMObject –property ClosedDate -Value $Date -SMobject $Inc
}
Add-Content -Path $LogFilename (".")
Save your powershell script to anywhere you want, then you can add as a scheduled task into Task Scheduler like below;
Configure and trigger the script for everyday every 1 hour period;
In "Program/script" section enter;
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
In "Add arguments" section enter;
C:\YourPathWhereScriptSaved\YourScriptFilename.ps1
If you want to Add the script as a task into SCSM console;
On the console go to Library-->Tasks section and create new task. Enter name and description, select "Incident" as target class, choose a custom management pack or create a new one.
Move down to command line tab and fill areas as in screenshot;
Now you will be able to see the task on your consoles Tasks Pane on the right side.
I hope this blog will help you getting over the issue.
C u!..
Friday, November 15, 2013
SCOM management packs list
It is useful to track all SCOM management pack updates and new releases from the link below;
http://social.technet.microsoft.com/wiki/contents/articles/16174.microsoft-management-packs.aspx
http://social.technet.microsoft.com/wiki/contents/articles/16174.microsoft-management-packs.aspx
Microsoft Silverlight release history
Hi,
Link below will help you follow Silverlight release history;
http://www.microsoft.com/getsilverlight/locale/en-us/html/Microsoft%20Silverlight%20Release%20History.htm
Link below will help you follow Silverlight release history;
http://www.microsoft.com/getsilverlight/locale/en-us/html/Microsoft%20Silverlight%20Release%20History.htm
Tuesday, November 12, 2013
How to install HP Proliant VMM 2012 Integration Kit on Windows Server 2012 R2 RTM
Today I am going to talk about HP Proliant VMM 2012 Integration Kit. Our test environment is VMM 2012 R2.
First thing to do is downloading latest Integration kit for VMM 2012 which is "Insight Control for System Center 7.3.1 DVD ISO - Sept 2013" for this post. You can download ISO package from the link below;
https://h20392.www2.hp.com/portal/swdepot/displayProductInfo.do?productNumber=HPICE
When you click the 7.2 link page will be scroll down to 7.2 download section. There after, when you click the download page will scroll down to the end and then you will see the receive for free button.
Then, Fill the form and then select Insight Control for System Center 7.3.1 DVD ISO - Sept 2013. Recommended to use HP download manager.
After download finished move to VMM management server and stop VMM services. Mount ISO and start autorun. Select VMM 2012 Integration Kit and follow the steps as follows;
Injecting drivers into WinPE boot image is another topic now discussed here therefore just click next.
Installed completed. Now start VMM services and move to Library tab, right click library server and click Refresh. You should see HP folder and subfolders like in the screenshot below;
Subscribe to:
Posts (Atom)