add pode and api scripts

This commit is contained in:
Alex Kup 2023-10-14 12:06:13 +03:00 committed by GitHub
parent 30a3d7711e
commit 94bc297ea1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 783 additions and 3 deletions

33
Scripts/Get-Size.psm1 Normal file
View file

@ -0,0 +1,33 @@
function Get-Size {
<#
.SYNOPSIS
Remote and local check use and all memory or space logical disk
For remote use applyed Invoke-Command via WinRM for memory and WMI for logical disk
.DESCRIPTION
Example:
Get-Size -disk localhost # default
Get-Size -memory localhost
.LINK
https://github.com/Lifailon
#>
Param (
$srv="localhost",
[switch]$memory,
[switch]$disk
)
if ($memory) {
if ($srv -like "localhost") {
$mem = Get-ComputerInfo
} else {
$mem = Invoke-Command -ComputerName $srv -ScriptBlock {Get-ComputerInfo}
}
$mem | select @{
Label="Size"; Expression={[string]($_.CsPhyicallyInstalledMemory/1mb)+" Gb"}},
@{Label="Free"; Expression={[string]([int]($_.OsFreePhysicalMemory/1kb))+" Mb"}}
} else {
gwmi Win32_logicalDisk -ComputerName $srv | select @{Label="Volume"; Expression={$_.DeviceID}},
@{Label="Size"; Expression={[string]([int]($_.Size/1Gb))+" Gb"}},
@{Label="Free"; Expression={[string]([int]($_.FreeSpace/1Gb))+" Gb"}},
@{Label="%Free"; Expression={[string]([int]($_.FreeSpace/$_.Size*100))+" %"}}
}
}