Showing posts with label PowerShell. Show all posts
Showing posts with label PowerShell. Show all posts

Sunday, December 28, 2014

List Applications Installed on a Remote or Local Machine with Powershell

This one-liner will list all application on your local computer, or remote computer.

If you do not include the -Computername parameter, it will list all applications on your local machine.

Get-wmi -Class Win32_Product -Computername <TypeComputerNameHere>  | Select-Object -Property Name

Tuesday, March 25, 2014

List Applications Installed on a Remote or Local Machine with Powershell

Joe Piggeé

This one-liner will list all application on your local computer, or remote computer. If you do not include the -Computername parameter, it will list all applications on your local machine.

Get-Wmi -Class Win32_Product -Computername TypeComputerNameHere | Select-Object -Property Name

 

*http://technet.microsoft.com/en-us/library/bb978526.aspx

PePELePuu

Thursday, October 17, 2013

Powershell: Restart a Remote Machine

Option 1: Prompt user for machine name to be restarted
CLS $cname = Read-Host "Enter Machine Name or IP Address" Restart-Computer -computerName $cname -Force

 Option 2: Enter the name directly in the code. cls Restart-Computer -computerName "EnterMachineNameHere" -Force

 Option 3: Reboot multiple Machines
cls $cname ="Server01, Server02, Server03" Restart-Computer -computer $cname -force

Joe Piggee





Powershell: List services on remote machine

# Use This to list\view services on remote server(s)
#Joe Piggee
---  Begin Code----
cls
gwmi win32_service -comp (gc c:\servers.txt) | select __server,name,startmode,state,status | Out-Gridview

--- End Code ---

Query Active Directory for a particular User

If you just want to know, for example, where a given user exists in your Active Directory, then searching for an account is a snap:
--- Begin code -----
cls
# sending LDAP query to Active Directory
#Change sAMAccountName for your query
$searcher = [ADSISearcher]'(&(objectClass=User)(objectCategory=person)(sAMAccountName=jpiggee*))'
# finding first match
$searcher.FindOne()
# finding ALL matches
$searcher.FindAll()
#This would find all user accounts with a SamAccountName that starts with "tobias". You can now use this approach to easily find out where an account is located:
# find account location
$searcher.FindAll() | Select-Object -ExpandProperty Path

---End Code ----

Joe Piggee

Get More Detailed Information Using GetDirectoryEntry()

To get more detailed information about an accounts using GetDirectoryEntry() to turn the search result into actual account objects:
# send LDAP query to Active Directory
$searcher = [ADSISearcher]'(&(objectClass=User)(objectCategory=person)(sAMAccountName=*))' 
# get 10 results max
$searcher.SizeLimit = 10 
# find account location
$searcher.FindAll() |
  # get account object
  ForEach-Object { $_.GetDirectoryEntry() } |
  # display all properties
  Select-Object -Property * |
  # display in a grid view window (ISE needs to be installed for this step)

  Out-GridView

# Joe Piggee

Wednesday, October 16, 2013

List machines with thier FQDN

Prerequisites: Create a file that has the list of machines netbios names, and create an empty systems.txt file on your root.
<#
Reference URL: http://blogs.technet.com/b/heyscriptingguy/archive/2010/03/11/hey-scripting-guy-march-11-2010.aspx
This file will read Machinelist from a file, try to get their DNS information,
and append that output to a txt file.
You can use the above mentioned URL for more information and exaples of the Try\Catch\Finally
#>
ForEach ($entry in (Get-Content c:\scripts\machinelist2.txt)) {
    Try {
        [net.dns]::GetHostEntry($entry).Hostname | Out-File -FilePath c:\systems.txt -Append
    } Catch {
        $entry | Out-File -FilePath c:\scripts\Machine_WithFQDN.txt -Append
    }
}
Joe P.

Friday, April 8, 2011

Exchange 2010: Update the Global Address List(GAL)


You can use the Shell to update a global address list (GAL). A GAL is a directory that contains entries for every group, user, and contact within an organization's implementation of Microsoft Exchange.
1. Open the EMC Shell.
2. Run the following command:
Update-GlobalAddressList -Identity <GlobalAddressListIdParameter> –DomainController
* Note that this starts the process, but the completion could take 15 min. to a couplehours.
 
More Information:
Syntax:
update-GlobalAddressList -Identity <GlobalAddressListIdParameter> [-Confirm [<SwitchParameter>]] [-DomainController <Fqdn>] [-WhatIf [<SwitchParameter>]]
Identity = The Identity parameter specifies a unique identifier of the GAL being updated. These unique identifiers include the common name (CN), GUID, or distinguished name (DN).