cls #################### #By Tony Unger #Purpose: inventory all services and user accounts running them with jobs # ## $myCol = @() $i =0 $servers = get-adcomputer -filter * | select -expand name $scriptblock = { param([string]$server) get-wmiobject win32_service -computername $Server | select * } $ServersCount = $Servers.count foreach($server in $Servers){ $i++ $running = @(Get-Job | Where-Object { $_.State -eq 'Running' }) Write-Progress -Activity "Gathering computer info" -status "Currently on $server -- $i of $ServersCount" -percentComplete ($i / $ServersCount*100) if ($running.Count -le 50) { Start-Job -ScriptBlock $scriptblock -Name $server -ArgumentList $server, $creds } else { $running | Wait-Job } } while ($running.Count -ge 1) { sleep 1 $running = @(Get-Job | Where-Object { $_.State -eq 'Running' }) } foreach ($job in Get-Job ){ $recjobs = Receive-Job -Keep -Job $job foreach ($recjob in $recjobs){ $Detail = New-Object PSObject $Detail | Add-Member Noteproperty Caption $recjob.Caption $Detail | Add-Member Noteproperty Name $recjob.name $Detail | Add-Member Noteproperty Startname $recjob.startname $Detail | Add-Member Noteproperty Server $recjob.__SERVER $myCol += $Detail } }
These are just random notes and programs that may have incomplete descriptions. Any scripts or programs use at your risk
Showing posts with label service. Show all posts
Showing posts with label service. Show all posts
Monday, April 18, 2016
Powershell: Get services and accounts used to run them on all computers using Jobs
Friday, November 21, 2014
SQL - If you don't have permission to logon fix
Purpose: If you don't want to put a SQL db into single user mode, you can try the following to give yourself permission to a SQL instance.
The following will open a command prompt as the built in security principal "System" using PSExec.
psexec -i -s -d cmd
From there open SQL management studio from within that command prompt.
ie:
c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\Ssms.exe"
I came up with this independently, but a simple google search will show you others have figured it out as well.
Should be able to now give yourself permissions to log on now depending on how the SQL was initially configured. If this doesn't work you will have to
Start the instance of SQL Server in single-user mode by using either the -m or -f options. Any member of the computer's local Administrators group can then connect to the instance of SQL Server as a member of the sysadmin fixed server role.
http://msdn.microsoft.com/en-us/library/dd207004.aspx
http://msdn.microsoft.com/en-us/library/dd207004.aspx
Tuesday, August 5, 2014
Powershell: Get list of all services accounts used on Windows servers in domain.
Purpose: This script will search AD for Windows Servers that are enabled and attempted to connect to each server and get a listing of all services and the accounts used to run them.
Note: This will take a while to run unless someone wants to make it multithreaded.
I just wrote this so there may need to be some bug fixes but in general it seemed to work.
Requirements: RSAT tools WMI
Import-Module activedirectory cls $ServicesReport = @() $AllServers = Get-ADComputer -Filter {(OperatingSystem -Like "Windows Server*")-and (enabled -eq "true")} -Property SamAccountName | select -expand Name $i = 0 foreach($Server in $AllServers) { $i++ Write-Host "Working on Server: $Server " $i " of " $AllServers.Count try { if (Test-Connection -ComputerName $Server -Quiet) { $Services = Get-WmiObject win32_service -ComputerName $Server | select Name, @{N="StartupType";E={$_.StartMode}}, @{N="ServiceAccount";E={$_.StartName}}, @{N="SystemName";E={$_.Systemname}} foreach ($Service in $Services) { $Detail = New-Object PSObject $Detail | Add-Member Noteproperty ServiceName $($Service.Name) $Detail | Add-Member Noteproperty StartupType $Service.StartupType $Detail | Add-Member Noteproperty ServiceAccount $Service.ServiceAccount $Detail | Add-Member Noteproperty SystemName $Service.Systemname $ServicesReport += $Detail } } } Catch { $Detail = New-Object PSObject $Detail | Add-Member Noteproperty ServiceName "NA" $Detail | Add-Member Noteproperty StartupType "NA" $Detail | Add-Member Noteproperty ServiceAccount "Error" $Detail | Add-Member Noteproperty SystemName $Server $ServicesReport += $Detail } } $ServicesReport | Export-Csv -Path c:\temp\test.csv -NoTypeInformation
Subscribe to:
Posts (Atom)
Powershell: Microsoft Graph to add new roles to application registration
PowerShell Script Bulk add new roles to application registration in azure. Update $roles with ,Us...
-
Here is an excel document I created that will ping a list of nodes in column A and give results in column B. There are much better tools th...
-
#reads event logs for filter and exports to $Date = ( Get-Date ).AddMinutes(-30) $LogName = 'Security' $ProviderName = ...
-
Using Google Chrome or MS Edge: Disable Javascript post page load. 1. Open console in dev tools 2. press ctrl - alt - p 3. In the run dial...