Update modules from WinAPI
This commit is contained in:
parent
31e13d4de1
commit
320872b22c
5 changed files with 192 additions and 165 deletions
|
|
@ -1,7 +1,6 @@
|
|||
function Get-Driver {
|
||||
Get-CimInstance -Class Win32_PnPSignedDriver | Select-Object DriverProviderName,
|
||||
FriendlyName,
|
||||
Description,
|
||||
DriverVersion,
|
||||
DriverDate
|
||||
Get-CimInstance -Class Win32_PnPSignedDriver |
|
||||
Select-Object DriverProviderName, FriendlyName, Description, DriverVersion, DriverDate |
|
||||
Group-Object DriverProviderName, FriendlyName, Description, DriverVersion, DriverDate |
|
||||
ForEach-Object {$_.Group[0]}
|
||||
}
|
||||
|
|
@ -1,16 +1,8 @@
|
|||
Import-Module ThreadJob -ErrorAction Ignore
|
||||
if (!(Get-Module ThreadJob)) {
|
||||
Install-Module ThreadJob -Scope CurrentUser -Force
|
||||
}
|
||||
|
||||
function Get-Hardware {
|
||||
param (
|
||||
$ComputerName,
|
||||
$Port = 8443,
|
||||
$User = "rest",
|
||||
$Pass = "api"
|
||||
)
|
||||
if ($null -eq $ComputerName) {
|
||||
Import-Module ThreadJob -ErrorAction Ignore
|
||||
if (!(Get-Module ThreadJob)) {
|
||||
Install-Module ThreadJob -Scope CurrentUser -Force
|
||||
}
|
||||
# Creat jobs
|
||||
Start-ThreadJob -Name SYS -ScriptBlock {Get-CimInstance Win32_ComputerSystem} | Out-Null
|
||||
Start-ThreadJob -Name OS -ScriptBlock {Get-CimInstance Win32_OperatingSystem} | Out-Null
|
||||
|
|
@ -133,16 +125,4 @@ function Get-Hardware {
|
|||
PortEstablishedCount = $PortEstablishedCount
|
||||
})
|
||||
$Collection
|
||||
}
|
||||
else {
|
||||
$url = "http://$ComputerName"+":$Port/api/hardware"
|
||||
$EncodingCred = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("${User}:${Pass}"))
|
||||
$Headers = @{"Authorization" = "Basic ${EncodingCred}"}
|
||||
try {
|
||||
Invoke-RestMethod -Headers $Headers -Uri $url
|
||||
}
|
||||
catch {
|
||||
Write-Error "Error connection"
|
||||
}
|
||||
}
|
||||
}
|
||||
41
Scripts/Get-ProcessPerformance.psm1
Normal file
41
Scripts/Get-ProcessPerformance.psm1
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
function Get-ProcessPerformance {
|
||||
param (
|
||||
$ProcessName
|
||||
)
|
||||
if ($null -eq $ProcessName) {
|
||||
$GetProcess = Get-Process -ErrorAction Ignore | Where-Object ProcessName -ne Idle
|
||||
}
|
||||
else {
|
||||
$GetProcess = Get-Process -Name $ProcessName -ErrorAction Ignore
|
||||
}
|
||||
if ($null -ne $GetProcess) {
|
||||
$ProcessPerformance = Get-CimInstance Win32_PerfFormattedData_PerfProc_Process
|
||||
$Collections = New-Object System.Collections.Generic.List[System.Object]
|
||||
foreach ($Process in $GetProcess) {
|
||||
$ProcPerf = $ProcessPerformance | Where-Object IDProcess -eq $Process.Id
|
||||
$Collections.Add([PSCustomObject]@{
|
||||
Name = $Process.Name
|
||||
ProcTime = "$($ProcPerf.PercentProcessorTime) %"
|
||||
IOps = $ProcPerf.IODataOperationsPersec
|
||||
IObsRead = $($ProcPerf.IOReadBytesPersec / 1mb).ToString("0.00 Mb")
|
||||
IObsWrite = $($ProcPerf.IOWriteBytesPersec / 1mb).ToString("0.00 Mb")
|
||||
RunTime = if ($null -ne $Process.StartTime) {
|
||||
$([string]([datetime](Get-Date) - $Process.StartTime) -replace "\.\d+$")
|
||||
}
|
||||
TotalTime = $Process.TotalProcessorTime -replace "\.\d+$"
|
||||
UserTime = $Process.UserProcessorTime -replace "\.\d+$"
|
||||
PrivTime = $Process.PrivilegedProcessorTime -replace "\.\d+$"
|
||||
WorkingSet = $($Process.WorkingSet / 1mb).ToString("0.00 Mb")
|
||||
PeakWorkingSet = $($Process.PeakWorkingSet / 1mb).ToString("0.00 Mb")
|
||||
PageMemory = $($Process.PagedMemorySize / 1mb).ToString("0.00 Mb")
|
||||
Threads = $Process.Threads.Count
|
||||
Handles = $Process.Handles
|
||||
#Path = $Process.Path
|
||||
#Company = $Process.Company
|
||||
#FileVersion = $Process.FileVersion
|
||||
#CommandLine = $Process.CommandLine
|
||||
})
|
||||
}
|
||||
$Collections | Sort-Object -Descending ProcTime,IOps,TotalTime
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,14 @@
|
|||
function Get-Software {
|
||||
Get-CimInstance Win32_Product | Select-Object Name,
|
||||
Get-CimInstance Win32_Product | Sort-Object -Descending InstallDate | Select-Object Name,
|
||||
Version,
|
||||
Vendor,
|
||||
InstallDate,
|
||||
@{
|
||||
name="InstallDate";expression={
|
||||
[datetime]::ParseExact($_.InstallDate, "yyyyMMdd", $null).ToString("dd.MM.yyyy")
|
||||
}
|
||||
},
|
||||
InstallLocation,
|
||||
InstallSource
|
||||
InstallSource,
|
||||
PackageName,
|
||||
LocalPackage
|
||||
}
|
||||
|
|
@ -1,9 +1,10 @@
|
|||
function Get-WinUpdate {
|
||||
Get-CimInstance Win32_QuickFixEngineering | Select-Object HotFixID,
|
||||
Get-CimInstance Win32_QuickFixEngineering | Sort-Object -Descending InstalledOn | Select-Object HotFixID,
|
||||
@{
|
||||
name="InstallDate";expression={
|
||||
$_.InstalledOn.ToString("dd.MM.yyyy")
|
||||
}
|
||||
},
|
||||
Description,
|
||||
InstalledBy,
|
||||
InstalledOn
|
||||
# wusa /uninstall /kb:123456
|
||||
# dism /Online /Get-Packages /format:table
|
||||
# dism /Online /Remove-Package /PackageName:Package_for_DotNetRollup_481~31bf3856ad364e35~amd64~~10.0.9206.1 /quiet /norestart
|
||||
InstalledBy
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue