[Requirements]
For vulnerability management in terms of Windows monthly update, it is a burdensome work either running remediation script or reinstalling MECM client for each PC manually.
Write PowerShell script which can run script or reinstall commands for a big list of PC
[OS]
Windows clinet/server
[Development Language]
PowerShell
[IDE]
PowerShell ISE
[Setting]
- RDP MECM(Microsoft EndPoint Configuration Manager) server
- Run PowerShell with admin. right
- Prepare a list of PC with csv file
<<CSV Format>>
- File format should be "csv"
- Computer names should be listed under "Asset Name" column
- Remove "rotork.co.uk" after the computer name if exists
- Modify csv file path and name in Import-CSV function
[Code]
#### setting for Configuration Manager module and site
cd "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin"
Import-Module .\ConfigurationManager.psd1
Set-Location RB1: #Rotork Bath Primary Site
#### Variables
$ScriptID = "1CDE1F81-A805-4D25-A2FF-2F8F4BE8BFD1" #EndPoint SUP Remediation script ID
#### Fetching PC names from SCV file
$ComputerNames = Import-CSV -Path "C:\Temp\VM_vulns_rtrkc2ay_20231221.csv"
$Computers = $ComputerNames."Asset Name"
#### Running script
$Computers | % {Invoke-CMScript -Device (Get-CMDevice -Name $_) -ScriptGuid $ScriptID}
#### Re-installing client
$Computers | % {Install-CMClient -DeviceName $_ -SiteCode "RB1" -AlwaysInstallClient $True -IncludeDomainController $True}
[Test]
Done successfully
[Lesson Learned]
There is always a way to shorthen/automate task, do not doubt
반응형
'ICT' 카테고리의 다른 글
[SQL] Procedure for Creating a New Account in Canteen System (0) | 2024.03.04 |
---|---|
[PowerShell] Sending ActiveDirectory User List Weekl (0) | 2024.02.29 |
[PowerAutomate] Unable to Fetch JSON Data from LogicApp (0) | 2023.12.21 |
[PowerAutomate] Odata Filter Queries (0) | 2023.12.20 |
[ServiceNow] Modifying workflow in Workflow Editor (0) | 2023.12.19 |
댓글