Issue
Code backup
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
function Get-LoggedUser
|
||||
{
|
||||
[CmdletBinding()]
|
||||
param
|
||||
(
|
||||
[string[]]$ComputerName
|
||||
)
|
||||
foreach ($comp in $ComputerName)
|
||||
{
|
||||
if ((Test-NetConnection $comp -WarningAction SilentlyContinue).PingSucceeded -eq $true)
|
||||
{
|
||||
$output = @{'Computer' = $comp }
|
||||
$output.UserName = (Get-WmiObject -Class win32_computersystem -ComputerName $comp).UserName
|
||||
}
|
||||
else
|
||||
{
|
||||
$output = @{'Computer' = $comp }
|
||||
$output.UserName = "offline"
|
||||
}
|
||||
[PSCustomObject]$output
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
function Get-MrTriggerStartService {
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName='Name')]
|
||||
param (
|
||||
[Parameter(ParameterSetName='Name',
|
||||
Position=0)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$Name = '*',
|
||||
|
||||
[Parameter(ParameterSetName='DisplayName')]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$DisplayName = '*'
|
||||
)
|
||||
|
||||
$Services = Get-WmiObject -Class Win32_Service -Filter "StartMode != 'Disabled' and Name like '$($Name -replace '\*', '%')' and DisplayName like '$($DisplayName -replace '\*', '%')'"
|
||||
|
||||
foreach ($Service in $Services) {
|
||||
|
||||
if (Test-Path -Path "HKLM:\SYSTEM\CurrentControlSet\Services\$($Service.Name)\TriggerInfo\") {
|
||||
|
||||
New-Object -TypeName PSObject -Property @{
|
||||
Status = $Service.State
|
||||
Name = $Service.Name
|
||||
DisplayName = $Service.DisplayName
|
||||
StartMode = "$($Service.StartMode) (Trigger Start)"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Get-MrTriggerStartService
|
||||
Reference in New Issue
Block a user