Powrshell: Show user info from groupmembers

Use the following powershell script to display the samaccount, name, mail information from all groupmembers. Also show if the account is enabled.

 

import-module activedirectory
Get-ADGroupMember “GROUP” | select samaccountname | %{Get-ADUser $_.samaccountname -Properties mail} | format-table samaccountname,name,mail,enabled

 

Point Client Computers to a New Print Server

'This script works well in a login script. When ran from a workstation
'it will loop thru all of the printers installed for the current logged on
'user and if they are connected to the old server they will be removed
'and then remaped to the new server. It will also attempt to descover
'which printer is the default printer in order to reset this if it is one
'of the printers that will be moved.
'
'Note: All of the printers must exist on the new server before this script
' should be run. If not then the printer will simply be removed from
' users profile and the script will not be able to reconnect them.
' "Print Migrator" is a utility that is part of the Windows 2000 and
' Windows 2003 resource kit. This will create all of the printers
' on the new server while maintaining all of their settings including
' print queue security. Keep in mind that for a time you will see
' duplicate printer if you do a search on printers, one advertisec
' from each server.
'
'We used this method to move just over 100 printers from one server to another
'and then ran this script as a logon script in a group policy. We let it run for
'a few days in order to allow for some users who don't logout every day have a
'chance to run it. All of our users profiles were updated and they didn't even
'know it was happening. We then deleted all of the printers from the old server.
'
'Note: The script does not run if you are Terminal serviced or SMS remote controling.

Option Explicit
Dim from_sv, to_sv, PrinterPath, PrinterName, DefaultPrinterName, DefaultPrinter
Dim DefaultPrinterServer, SetDefault, key
Dim spoint, Loop_Counter, scomma
Dim WshNet, WshShell
Dim WS_Printers
DefaultPrinterName = ""
spoint = 0
scomma = 0
SetDefault = 0
set WshShell = CreateObject("WScript.shell")

from_sv = "\\old" 'This should be the name of the old server.
to_sv = "\\new" 'This should be the name of your new server.

'Just incase their are no printers and therefor no defauld printer set
' this will prevent the script form erroring out.
On Error Resume Next
key = "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\Device"
DefaultPrinter = LCase(WshShell.RegRead (key))

If Err.Number <> 0 Then
	DefaultPrinterName = ""
else
'If the registry read was successful then parse out the printer name so we can 
' compare it with each printer later and reset the correct default printer
' if one of them matches this one read from the registry.
spoint = instr(3,DefaultPrinter,"\")+1

DefaultPrinterServer = left(DefaultPrinter,spoint-2)

	if lcase(DefaultPrinterServer) = from_sv then
		DefaultPrinterName = mid(DefaultPrinter,spoint,len(DefaultPrinter)-spoint+1)
		scomma = instr(DefaultPrinterName,",")
		DefaultPrinterName = left(DefaultPrinterName,scomma -1)
	end if
end if

Set WshNet = CreateObject("WScript.Network")
Set WS_Printers = WshNet.EnumPrinterConnections

'You have to step by 2 because only the even numbers will be the print queue's
' server and share name. The odd numbers are the printer names.
For Loop_Counter = 0 To WS_Printers.Count - 1 Step 2
	'Remember the + 1 is to get the full path ie.. \\your_server\your_printer.
	PrinterPath = lcase(WS_Printers(Loop_Counter + 1))

	'We only want to work with the network printers that are mapped to the original
	' server, so we check for "\\Your_server".
	if lcase(LEFT(PrinterPath,len(from_sv))) = from_sv then
		'Now we need to parse the PrinterPath to get rhe Printer Name.
		spoint = instr(3,PrinterPath,"\")+1
		PrinterName = mid(PrinterPath,spoint,len(PrinterPath)-spoint+1)
		'Now remove the old printer connection.
		WshNet.RemovePrinterConnection from_sv+"\"+PrinterName
		'and then create the new connection.
		'Do not create c6100
		if lcase(PrinterName) <> "c6100" then
			WshNet.AddWindowsPrinterConnection to_sv+"\"+PrinterName
			'If this printer matches the default printer that we got from the registry then
			' set it to be the default printer.
			if DefaultPrinterName = PrinterName then
				WshNet.SetDefaultPrinter to_sv+"\"+PrinterName
			end if
		end if
	end if
Next
Set WS_Printers = Nothing
Set WshNet = Nothing
Set WshShell = Nothing

' wscript.echo "Printers Migrated"

 

A VBS script to alter client network printers to a new server:

 

source: http://gallery.technet.microsoft.com/scriptcenter/0cb47cac-42d5-4e9d-a85e-6e4b1ef7883c/view/Discussions#content

CLI uninstall Powerchute Business Edition from Windows 2012 Core

Run the following command to deinstall PBE from the Command Line Interface

 

PowerChute Business Edition Agent:

“C:\Program Files (x86)\InstallShield Installation Information\{BCE9F441-9027-4911-82E0-5FB28057897D}\setup.exe” -runfromtemp -l0x0409 AnyText -removeonly

PowerChute Business Edition Server:

“C:\Program Files (x86)\InstallShield Installation Information\{A6491A4A-AAA0-4892-BFEF-ECD6CECE2FF3}\setup.exe” -runfromtemp -l0x0409 AnyText -removeonly

PowerChute Business Edition Console:

“C:\Program Files (x86)\InstallShield Installation Information\{0F86FD09-BA63-4E45-A70B-604C1106C2F2}\setup.exe” -runfromtemp -l0x0409 AnyText -removeonly

 

The corresponding directories in “C:\Program Files (x86)\InstallShield Installation Information” could also be removed

KMS Client Setup Keys

Computers that are running volume licensing editions of Windows 8, Windows Server 2012, Windows 7, Windows Server 2008 R2, Windows Vista, and Windows Server 2008 are, by default, KMS clients with no additional configuration needed.

If you are converting a computer from a KMS host, MAK, or retail edition of Windows to a KMS client, install the applicable setup key (GVLK) from the following tables

To install a client setup key, open an administrative command prompt on the client, type slmgr /ipk <setup key> and press ENTER.

Operating system edition KMS Client Setup Key
Windows 8 Professional NG4HW-VH26C-733KW-K6F98-J8CK4
Windows 8 Professional N XCVCF-2NXM9-723PB-MHCB7-2RYQQ
Windows 8 Enterprise 32JNW-9KQ84-P47T8-D8GGY-CWCK7
Windows 8 Enterprise N JMNMF-RHW7P-DMY6X-RF3DR-X2BQT
Windows Server 2012 Core BN3D2-R7TKB-3YPBD-8DRP2-27GG4
Windows Server 2012 Core N 8N2M2-HWPGY-7PGT9-HGDD8-GVGGY
Windows Server 2012 Core Single Language 2WN2H-YGCQR-KFX6K-CD6TF-84YXQ
Windows Server 2012 Core Country Specific 4K36P-JN4VD-GDC6V-KDT89-DYFKP
Windows Server 2012 Server Standard XC9B7-NBPP2-83J2H-RHMBY-92BT4
Windows Server 2012 Standard Core XC9B7-NBPP2-83J2H-RHMBY-92BT4
Windows Server 2012 MultiPoint Standard HM7DN-YVMH3-46JC3-XYTG7-CYQJJ
Windows Server 2012 MultiPoint Premium XNH6W-2V9GX-RGJ4K-Y8X6F-QGJ2G
Windows Server 2012 Datacenter 48HP8-DN98B-MYWDG-T2DCC-8W83P
Windows Server 2012 Datacenter Core 48HP8-DN98B-MYWDG-T2DCC-8W83P
Operating system edition KMS Client Setup Key
Windows 7 Professional FJ82H-XT6CR-J8D7P-XQJJ2-GPDD4
Windows 7 Professional N MRPKT-YTG23-K7D7T-X2JMM-QY7MG
Windows 7 Professional E W82YF-2Q76Y-63HXB-FGJG9-GF7QX
Windows 7 Enterprise 33PXH-7Y6KF-2VJC9-XBBR8-HVTHH
Windows 7 Enterprise N YDRBP-3D83W-TY26F-D46B2-XCKRJ
Windows 7 Enterprise E C29WB-22CC8-VJ326-GHFJW-H9DH4
Windows Server 2008 R2 Web 6TPJF-RBVHG-WBW2R-86QPH-6RTM4
Windows Server 2008 R2 HPC edition TT8MH-CG224-D3D7Q-498W2-9QCTX
Windows Server 2008 R2 Standard YC6KT-GKW9T-YTKYR-T4X34-R7VHC
Windows Server 2008 R2 Enterprise 489J6-VHDMP-X63PK-3K798-CPX3Y
Windows Server 2008 R2 Datacenter 74YFP-3QFB3-KQT8W-PMXWJ-7M648
Windows Server 2008 R2 for Itanium-based Systems GT63C-RJFQ3-4GMB6-BRFB9-CB83V
Operating system edition KMS Client Setup Key
Windows Vista Business YFKBB-PQJJV-G996G-VWGXY-2V3X8
Windows Vista Business N HMBQG-8H2RH-C77VX-27R82-VMQBT
Windows Vista Enterprise VKK3X-68KWM-X2YGT-QR4M6-4BWMV
Windows Vista Enterprise N VTC42-BM838-43QHV-84HX6-XJXKV
Windows Web Server 2008 WYR28-R7TFJ-3X2YQ-YCY4H-M249D
Windows Server 2008 Standard TM24T-X9RMF-VWXK6-X8JC9-BFGM2
Windows Server 2008 Standard without Hyper-V W7VD6-7JFBR-RX26B-YKQ3Y-6FFFJ
Windows Server 2008 Enterprise YQGMW-MPWTJ-34KDK-48M3W-X4Q6V
Windows Server 2008 Enterprise without Hyper-V 39BXF-X8Q23-P2WWT-38T2F-G3FPG
Windows Server 2008 HPC RCTX3-KWVHP-BR6TB-RB6DM-6X7HP
Windows Server 2008 Datacenter 7M67G-PC374-GR742-YH8V4-TCBY3
Windows Server 2008 Datacenter without Hyper-V 22XQ2-VRXRG-P8D42-K34TD-G3QQC
Windows Server 2008 for Itanium-Based Systems 4DWFP-JF3DJ-B7DTH-78FJB-PDRHK

 

source: http://technet.microsoft.com/en-us/library/jj612867.aspx

 

Uninstall software on remote computers using WMIC

  • In a window, type Runas /user:YourUsername@UPNsuffix cmd.exe (or Runas /user:domain\username cmd.exe) where YourUsername is your domain admin username or any username with admin privileges on the remote computer and UPNsuffix is your UPN suffix. Let’s suppose I use [email protected]
  • In the command prompt window type the password for user [email protected] and press Enter
  • Type WMIC
  • Now, list all Nokia software on a specific computer using the command /node:COMPUTERNAME product where vendor=”Nokia” get name, version
  • Once we know the software name, we can uninstall specific product using the following command /node:COMPUTERNAME product where name=”Nokia PC Suite” call uninstall. You will see a message like Execute (\\COMPUTERNAME\ROOT\CIMV2:Win32_Product.IdentifyingNumber=”{225DB4AA-3CFF-47E8-B3C8-6DAD713E986E}”,Name=”Nokia PC Suite”,Version=”7.1.51.0″)->Uninstall() (Y/N/?)? Type Y and wait for the result.

 

http://community.spiceworks.com/how_to/show/179-using-a-command-line-to-uninstall-software-on-remote-pcs

Script – Get HP Serial Numbers

To get a list of HP Serial numers run the following Powershell script. Place the servernames/ipaddresses you want to check in the serverlist parameter.

 

#
# Get HP Serial Numbers from server text file
#
# Written by Bastiaan van Leeuwen
#
# Change $serverlist parameter to the right text file

$serverlist = "d:\script\servers.txt"
$username = Get-Credential domain\user

foreach($server in get-content $serverlist)
{
gwmi win32_systemenclosure -computer "$server" -credential $username –ErrorAction SilentlyContinue | 
select __SERVER,serialnumber
}

 

SCRIPT – Computer Inventory

The Computer Inventory Script enumerates Hardware, OS, System, Processor, Memory, Disk, and Network information and neatly organizes it in an Excel file. I’ve provided Version 2 of the script that allows you to choose a number of computer resources; all computers in the domain, all servers in the domain, computers from a list maintained in a text file, and the ability manually pick a computer. Version 2 of the PowerShell script also allows you to send credential information should you wish to logon the remote computer with an alternative user account. This is helpful for DMZ servers as well as stand alone servers that are not members of your domain.

source: http://www.powershellpro.com/why-i-no-longer-hate-writing-documentation/614/

 

[wpdm_file id=78]

Backup en restore windows FSRM Quotas

To get a list of quota’s in a text file: dirquota q l > all_quotas.txt

To backup the complete quota database first stop the FSRM services, copy the SRM directory and restart the FSRM services. To be able to copy the SRM directory you need rights on the System Volume Information directory.

 

1. Stop the FSRM services

net stop srmSvc
net stop srmReports
net stop quota
net stop Datascrn

2. Copy SRM for the disk you want to a backup folder, or restore them from a backup folder

3. Start the FSRM services

net start Datascrn
net start quota
net start srmReports
net start srmSvc