Wednesday, June 3, 2020

IMP - WMI & Powershell Commands


Remote session using Psexec 

PSEXEC \\hostname -s -h -d powershell.exe "enable-psremoting" -force

For enabling the PS session for remote machine

Enter-PSSession -ComputerName RDP-xxxxxx-VSB
Enable-PSRemoting -Force
winrm quickconfig    #### Enable remote service

Wmi Query : Run Command on power shell console for system info

Get-WmiObject -List
wmic CSProduct list
wmic CSproduct get model
wmic CSproduct get version
Wmic os list brief

Get-WmiObject -Class Win32_OperatingSystem
WMIC COMPUTERSYSTEM GET /?
Install-Module PSWindowsUpdate -force
Get-wmiobject win32_computersystem -computer $_ | select-object systemtype
(Get-WmiObject Win32_OperatingSystem).OSArchitecture

Nomad client:

C:\Program Files\1E>nomadbranch.exe>  /relicense=XXX-XXXX-XXXX-XXXX
CacheCleaner.exe -deletepkg=cp100372 -pkgver=19    
Get-Service -Name NomadBranch -ComputerName CHE-DAA0218-01 | Restart-Service
C:\Program Files\1E\NomadBranch>CacheCleaner.exe -MaxcacheAge=30 
Pending reboot machine

SCCM Client And Sys Registry:

Get-WmiObject -Namespace root\ccm -Class * -List
Get-WmiObject -namespace root\ccm -class sms_client -computername RDP-cxy0801-vsb
Get-WmiObject -Namespace root\ccm -Class SMS_Client
Get-WmiObject -Query "SELECT * from Win32_bios"
Get-WmiObject -List
GET install product 
Get-WmiObject -Class Win32_Product -ComputerName RDP-   XXXX-vsb
Get-WmiObject -Class Win32_product -ComputerName RDP-CXY0801-VSB | Where {$_.Name -match 'SQL' }
Get-WmiObject win32_product | where {$_.Name -match 'office'} | select name, version
Get-WmiObject win32_product -ComputerName RDP-CXY0801-VSB | where {$_.Name -match 'office'} | select name, version

Invoke-command -computer BLR-P-CMSS01 {Get-ItemProperty HKLM:\Software\1E\NomadBranch\ | select SpecialNetShare,SigsFolder}

Invoke-WMIMethod -ComputerName RDP-CXY0801-V76 -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000108}"

Get-ItemProperty -Path HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select DisplayName,version
 
Delete Reg:

Invoke-Command -ComputerName xxx-xxx-xxx -ScriptBlock {Remove-Item -Path 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{083988D7-BDA9-4244-983B-409A634BBC09}' -Confirm:$false}

WindowsVersion:

Invoke-command -computer BLA-BXK0815-1 {(Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name ReleaseId).ReleaseId}  

System Info:

wmic computersystem get model,name,manufacturer,systemtype

GET OU detail:

Get-ADComputer -Filter "Name -like 'BLR-CXY0801*'"
Invoke-CimMethod -Namespace root/ccm/ClientSDK -ClassName CCM_ClientUtilities -MethodName DetermineIfRebootPending

Get WMI classes:

Get-CimClass
Get-CimClass -ClassName win32*
Get-CimClass -ClassName win32* | where CimClassMethods -ne $null  | select CimClassName,CimClassMethods

Get-WmiObject -Query 'Select * From Meta_Class WHERE __Class LIKE "win32%"' | Where-Object { $_.PSBase.Methods } | Select-Object Name, Methods

Get-WmiObject -List | Where { $_.name -match 'User'}
gwmi win32_product -Filter "Name like 'google%'"  | ft name, version, ident*,vendor,caption

Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object {$_.DisplayName -match 'amazon'} | Select-Object -Property DisplayName,DisplayVersion,UninstallString,Publisher | FT

Invoke Command:

Get-ItemProperty -Path HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select DisplayName,version

Set-ItemProperty -Path hklm:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Ext\CLSID -Name '{B3A6DA95-9243-48E9-AF2E-52F4FF155B9D}' -Value 1 -Type STRING

Invoke-Command -cn wfe0,wfe1 -ScriptBlock {Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | select DisplayName, Publisher, InstallDate

No comments:

Post a Comment