Tuesday, October 29, 2013

Display or Not the last login name

To hide or show the last login name ( username ) to login to the computer



HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System


dontdisplaylastusername
 
- value of 1 hides the last name
- value of 0 shows the last name

Basically either forces users to enter their username or not every login

Tuesday, October 8, 2013

GP Management Reporter license error

GP Management Reporter 2012

"Evaluation License period expired"  error when launching Report Designer.

Login and go to Tools > Registration > enter your Registration Keys.

If you have a default company selected, you cannot get to the above.  You have to use SQL Management Studio and,

delete from dbo.license   from the Management Reporter database.

Thursday, September 26, 2013

Export email addresses from Exchange

For Exchange 2010, use powershell

Exports a lot of information
get-mailboxserver | get-mailbox | export-csv FILENAME.CSV


Exports less information, use above to see what fields can be included
get-mailbox -resultsize unlimited -recipienttypedetails usermailbox | get-user | select-object firstname,lastname,windowsemailaddress | export-csv FILENAME.CSV

Thursday, September 19, 2013

Set auto-reply for another mailbox

Can use Exchange Control Panel to set

https://servername/ecp

Manage My Organization, select Another User, select the user, on right side select Tell others on vacation


Using Exchange 2010 Powershell

Setting the auto-reply

Set-MailboxAutoReplyConfiguration email@domain.com -AutoReplyState Enabled -ExternalMessage "MESSAGE HERE" -InternalMessage "MESSAGE HERE"

For AutoReplyState, can change Enabled to Scheduled .  If so, syntax should be,
-AutoReplyState Scheduled -StartTime "9/15/2013" -Endtime "9/28/2013"

To retrieve auto-reply settings for a mailbox

Get-MailboxAutoReplyConfiguration email@domain.com


Disables auto-reply for a mailbox

Set-MailboxAutoReplyConfiguration email@domain.com -AutoReplyState Disabled -ExternalMessage $null -InternalMessage $null

Monday, August 12, 2013

VMWare ESXi 5.x / 6.x changing the IOPS setting

vSphere has Native Multi Pathing (NMP) that offers the Round Robin (RR) Path Selection Policy (PSP).  Round Robin send all IOPS down a single active path until the number of IOPS sent down that path reaches the limit defined by the IOOperation Limit setting before it moves to the next available active path.  It will cycle through all active paths.

The default setting for Round Robin PSP is 1000 IOPS. 

Changing the IOPS setting is done through the vSphere CLI.  The commands below are for ESXi 5.x , the commands are different for ESXi 4.x.

ESXi 5.x
Set the IOPS for a datastore

esxcli --server=192.168.1.10 --username=root storage nmp psp roundrobin deviceconfig set -d naa.600xxxxxxxxxxxxxxxxxxxxxx -t iops -I 1    (changes setting to 1)


Check the IOPS setting for a datastore

esxcli --server=192.168.1.10 --username=root storage nmp psp roundrobin deviceconfig get -d naa.600xxxxxxxxxxxxxxxx


Set the IOPS back to default (1000)
esxcli --server=192.168.1.10 --username=root storage nmp psp roundrobin deviceconfig set -d naa.600xxxxxxxxxxxxxxxxxxxxxx -t default


NOTE:
- the setting must be set FOR EACH datastore on EACH host
- can also have the setting change by number of bytes instead of each IOP
       -t bytes -B 262144   (would change setting to switch paths every 256K)


VMWare KB article,  http://kb.vmware.com/kb/2069356

for i in `esxcfg-scsidevs -c |awk '{print $1}' | grep naa.xxx`; do esxcli storage nmp psp roundrobin deviceconfig set --type=iops --iops=1 --device=$i; done






Wednesday, August 7, 2013

Split a PST file into yearly archives / Archive based on year

Split a PST file into yearly archives / Archive based on year

Can be done using the Archive feature in Outlook.  You MUST configure Outlook to archive based on Received date first.

- open the Archive feature (Outlook 2010, File->Cleanup Tools->Archive)
- click on the top level folder to select the entire mailbox rather than the currently selected folder
- set the "Archive items older than:" date to the 1st of January fo the year after you want to create your first archive for (ex. for a 2010 archive, set to January 1st, 2011)
- specify a name and location for your PST file for 2010
- after archiving has finished, repeat the steps but change the date for another year

Outlook Archive based on Received Date

Outlook Archive based on Received Date

By default Outlook archives emails based on Modified date.  This can cause emails to "get stuck" in your mailbox (or pst) forever.

A Registry change can change the behaviour to archive based on Received date.

Outlook 2010
HCU/Software/Microsoft/Office/14.0/Outlook/Preferences
NAME:   ArchiveIgnoreLastModifiedTime
TYPE: REG_DWORD
VALUE: 1


Emails will now be archived based on Received date, Calendar items based on Scheduled date and Task items based on Completed date.

Tuesday, July 30, 2013

Updating VMWare tools for the Untangle Router

To update the tools just select "Update/install tools" in ESXi.
then go in to the host terminal and run: 

"mount /media/cdrom" Mount the tool CD

"cd /media/cdrom" Go to the CD

"cp VMware*.tar.gz /tmp" Copy the Install archive to temp folder

"cd /tmp" go to Temp folder

"tar -xvcf VMware*.tar.gz" Unpack Archive

"cd vmware-tools-distrib" change Folder to the installation folder.

"./vmware-install.pl -d" Install with the default settings

"umount /media/cdrom" Unmount the Tools CD

Thursday, July 25, 2013

Photos in Active Directory



Need to be running Exchange 2010 SP1 , or else you need to make schema changes to the AD.

AD includes the Picture attribute to store thumbnail photos, its ldap name is thumbnailPhoto.

Since it is just a thumbnail, the recommended size in pixels is 96 x 96 , size should be less than 10K .

Use Exchange 2010's cmdlet,  Import-RecipientDataProperty   to import the photos.
ex.
Import-RecipientDataProperty -Identity "FULL NAME" -Picture -FileData ([Byte[]]$(Get-Content -Path "C:\pictures\FULLNAME.jpg" -Encoding Byte -ReadCount 0))


Much easier way is to use this free tool, http://www.codetwo.com/freeware/active-directory-photos/

or,

An Active Directory extension available here, http://www.dewdney.co.uk/adext/adext.zip

Monday, July 22, 2013

Allow non-Administrators to install printers

This is for a domain environment, Windows 2008 R2 with Windows 7 Pro clients.

Use Group Policy.

Computer Configuration / Policies / Administrative Templates / Printers / Point and Print Restrictions
and possibly (I've not had to do the User side, works with just Computer side done)
User Configuration / Policies / Administrative Templates / Control Panel / Printers / Point and Print Restrictions
- enabled
- set your print server name (not necessary, but if you do it is SERVER.DOMAIN.COM)
- Security Prompts, When Installing Drivers for a new connection = Do not show warning or elevation prompt

Also, make sure users have permission to install printer drivers,
Computer Configuration / Policies / Administrative Templates / System / Driver Installation
- enable "Allow non-administrators to install drivers for these devices setup classes"
- Add the Class ID's for
Printers,  {4d36e979-e325-11ce-bfc1-08002be10318}
PNPPrinters,   {4658ee7e-f050-11d1-b6bd-00c04fa372a7}

You may need different Class ID's.



Thursday, July 18, 2013

ftp script to download

- create a directory to place your downloaded files in
- create text file to hold the ftp commands
  example  website.txt
  open website.com
  username
  password
  cd /remotedirectory
  bin
  put/get "filename.wat"
  disconnect
  bye

- execute the ftp command,  ftp -s:website.txt

- can execute from a batch file as well

Friday, June 21, 2013

Manually Patch ESXi 5.1

- download necessary patches from VMWare
- upload patch file to a datastore local to the ESXi installation (place patches into patch directory)
- place server into maintenance mode

If you have the vCLI tools installed onto your computer you can execute patch remotely
- command prompt and navigate to the bin directory of the CLI tools, execute the following command to apply the update

esxcli --server=192.168.0.25 --username=root software vib update --depot=/vmfs/volumes/DATASTORE/DIRECTORY/ESXi510-201305001.zip

- reboot the server to complete the update

Without the CLI tools available you will have to SSH into the ESXi server to execute and apply the update.
- start the SSH service on the ESXi host; Configuration Tab, Security Profile, Properties in the upper right, highlight SSH, Options button
- SSH into the ESXi host as root
- execute the command to apply the update,

esxcli software vib update --depot=/vmfs/volumes/DATASTORE/DIRECTORY/ESXi510-201305001.zip

- reboot the server to complete the update

Wednesday, June 5, 2013

Powershell command to backup / copy

Use this Powershell command to copy / backup files to remote filesystem.

Copy-Item "C:DIRECTORYTOCOPY*" "DESTINATIONDIR" -Recurse -Force | Out-Null

Change the DIRECTORYTOCOPY & DESTINATIONDIR to appropriate parameters.
- recurse option forces it to copy subfolders and contents
- force option tells it to create new folders in destination that are missing
out-null tells it to finish this line before moving on to the next line of code

Save as a .ps1 extension, then create a batch file to call the .ps1 file.  The batch file can be scheduled.

Monday, June 3, 2013

Apache - Site Maintenance page

Site Under Maintenance Page

In apache config file make sure,
RewriteEngine On

Then add the following lines somewhere (usually within the appropriate virtual host container),

     RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f
     RewriteCond %{REQUEST_FILENAME} !/maintenance.html
     RewriteCond %{REQUEST_FILENAME} !/logo.jpg
     RewriteCond %{REQUEST_FILENAME} !/loading.gif
     RewriteRule ^.*$ /maintenance.html [L]


Then inside the root of the virtual host's directory, add the above files called for your maintenance page. 

When you want to turn the page ON, simply make sure the maintenance.html file is there.

To turn the page OFF, simply rename the maintenance.html file to maintenance.html.REMOVE

Tuesday, May 28, 2013

CentOS - Check for large files & directories


FILES

Check for large files over 9 MB in the file system,  in this example /home :
find /home -type f -xdev -size +9000000c -exec ls -ldh {} \;|sort -k 5n

- The xdev option tells it not to cross mount points.
- The exec option instructs the find command to issue an ls -ldh against any file that meets our criteria.
- The resulting matches are substituted inside the {}, and then executed.
- Then the results of the ls -ldh output is sent to the sort and sorted based on the 5th column which is the size column.


DIRECTORIES

du -H --max-depth=1 /home/ | sort -n -r

Friday, May 24, 2013

Powershell script to Delete/Remove AD user account & Exchange mailbox

1. Create the file ADUserDel.ps1 .  Will dump the mailbox to the location, \\SERVERNAME\SHARENAME\mailbox.pst

$Name = Read-Host "Please enter a mailbox to archive"
New-MailboxExportRequest -Mailbox $Name -FilePath \\SERVERNAME\SHARENAME\$Name.pst
while ((Get-MailboxExportRequest -Mailbox $Name | Where {$_.Status -eq "Queued" -or $_.Status -eq "InProgress"}))
{
sleep 60
}
Get-MailboxExportRequest -Mailbox $Name | Remove-MailboxExportRequest -Confirm:$false
Remove-Mailbox -Identity $Name -Confirm:$false

2. Execute the file from within the Exchange Shell

Network Policy Server (NPS) Backup

1. Create a batch file.  Will keep 7 days of backup files.

cd c:\
cd \Backup\nps
netsh nps export filename="c:\backup\nps\%Date:~0,3%.xml" exportPSK=YES
netsh nps show config > "c:\backup\nps\%Date:~0,3%Readable.txt

2. Schedule the batch file to run once a day.

3. First netsh nps line exports the config into an xml file.  The xml file can be imported using
netsh nps import  , command.  Second netsh nps line will dump the config into a readable text file for information.



DHCP Scheduled Backup

1. Create a batch file for DHCP backup.  This file will keep the last 7 days of dhcp backups.

cd c:\
cd \Backup\dhcp
rmdir %Date:~0,3%
md %Date:~0,3%
cd %Date:~0,3%
netsh dhcp server export dhcpdb all

2. Create a scheduled job to run the batch file every day

Thursday, May 23, 2013

MDT 2012 - custom files

Not necessary to do this, but helps.  Files go in the D:\DeploymentShare\Control  folder.  Be sure to change all values between *CHANGE*

BOOTSTRAP.INI

[Settings]
Priority=Default

[Default]
DeployRoot=\\*SERVERNAME*\DeploymentShare$
SkipBDDWelcome=YES
UserID=*USERNAME*
UserDomain=*DOMAINNAME*
UserPassword=*PASSWORD*

________________________________________
DOMAINOULIST.XML

<?xml version="1.0" encoding="utf-8"?>
<DomainOUs>
<DomainOU>OU=Desktops,OU=Computers,OU=SCC,DC=domain,DC=local</DomainOU>
<DomainOU>OU=Laptops,OU=Computers,OU=SCC,DC=domain,DC=local</DomainOU>
<DomainOU>OU=Others,OU=Computers,OU=SCC,DC=domain,DC=local</DomainOU>
</DomainOUs>

________________________________________
CUSTOMSETTINGS.INI

[Settings]
Priority=Default
Properties=MyCustomProperty
Properties=DriversApplied

[Default]
OSInstall=Y
SkipCapture=YES
SkipAdminPassword=YES
AdminPassword=*PASSWORD*
SkipProductKey=YES
SkipComputerBackup=YES
SkipBitLocker=YES
SkipApplications=NO
SkipUserData=YES
KeyboardLocale=en-US
UserLocale=en-CA
UILanguage=en-US
SkipDomainMembership=NO
JoinDomain=*domain.local*
DomainAdmin=*USERNAME*
DomainAdminDomain=*DOMAIN*
DomainAdminPassword=*PASSWORD*
SkipTimeZone=YES
TimeZone=035
TimeZoneName=Eastern Standard Time
WSUSServer=http://*SERVERNAME*:8530
DriversApplied=NO

MDT 2012 - Drivers using selection profiles


MDT 2012 – Drivers

Using selection profiles for hardware drivers.  Works well when most systems are standard models from vendors (HP, Dell, …).

STEP 1

Need a custom property called DriversApplied and set it to NO in the CustomSettings.ini

[Settings]

Priority=Default

Properties=DriversApplied

[Default]

DriversApplied=NO

 

STEP 2

Organize your drivers in the Deployment Workbench under the Out-of-Box Drivers.  Import the drivers into the appropriate folder.



STEP 3

Create a selection profile for each model/OS/architecture you have.  Created under Advanced Configuration.



Also, you will need a “catch all” selection profile to catch all others that do not match an exact profile.  Simply create another profile, but select every single folder under x86 to “catch” all 32 bit drivers.

 

STEP 4

After creating all your driver selection profiles (both machine specific and a “catch all) , you have to modify the task sequence.  In the Preinstall phase, REMOVE the Inject Drivers step and create a group called Inject Drivers.  Then create a subgroup inside for each model you have created a selection profile for.



 

On each subgroup, select it, on the right select the Options Tab, Add a Query WMI .  Query is,

Select * from Win32_ComputerSystem where Model like 'HP EliteBook 2540p%'



Use PDQ Inventory, Computer selected to find the exact text for the Model to match the query.

In each subgroup for each model, you have to create 2 steps, one to inject the drivers from the selection profile



 and another to change the value of DriversApplied to YES.



 

Final step in this group is to create a the “catch all” inject drivers step,



Set it to only run when DriversApplied equals NO.



 

Thursday, May 16, 2013

Backup local files to home share

For Windows 7, batch file to copy contents of users' Desktop and Documents to a home share.

robocopy "%USERPROFILE%\Desktop" "%HOMESHARE%\Desktop" /MIR /R:2 /W:3
robocopy "%USERPROFILE%\Documents" "%HOMESHARE%\Documents" /MIR /R:2 /W:3


For XP or where robocopy does not work.

rd /S /Q "%HOMESHARE%\Desktop"
rd /S /Q "%HOMESHARE%\Documents"
mkdir "%HOMESHARE%\Desktop"
mkdir "%HOMESHARE%\Documents"
xcopy "%USERPROFILE%\Desktop" "%HOMESHARE%\Desktop" /S /E /Y /C
xcopy "%USERPROFILE%\Documents" "%HOMESHARE%\Documents" /S /E /Y /C

Windows Variables

Variable Type Description
%ALLUSERSPROFILE% Local Returns the location of the All Users Profile.
%APPDATA% Local Returns the location where applications store data by default.
%CD% Local Returns the current directory string.
%CMDCMDLINE% Local Returns the exact command line used to start the current Cmd.exe.
%CMDEXTVERSION% System Returns the version number of the current Command Processor Extensions.
%COMPUTERNAME%  System Returns the name of the computer.
%COMSPEC%  System Returns the exact path to the command shell executable.
%DATE%  System Returns the current date. Uses the same format as the date /t command. Generated by Cmd.exe.
%HOMEDRIVE%  System Returns which local workstation drive letter is connected to the user's home directory. Set based on the value of the home directory. The user's home directory is specified in Local Users and Groups.
%HOMEPATH%  System Returns the full path of the user's home directory. Set based on the value of the home directory. The user's home directory is specified in Local Users and Groups.
%HOMESHARE%  System Returns the network path to the user's shared home directory. Set based on the value of the home directory. The user's home directory is specified in Local Users and Groups.
%LOGONSEVER%  Local Returns the name of the domain controller that validated the current logon session.
%NUMBER_OF_PROCESSORS%  System Specifies the number of processors installed on the computer.
%OS%  System Returns the operating system name. Windows 2000 displays the operating system as Windows_NT.
%PATH% System Specifies the search path for executable files.
%PATHEXT% System Returns a list of the file extensions that the operating system considers to be executable.
%PROCESSOR_ARCHITECTURE%  System Returns the chip architecture of the processor. Values: x86 , IA64.
%PROCESSOR_IDENTFIER% System Returns a description of the processor.
%PROCESSOR_LEVEL%  System Returns the model number of the processor installed on the computer.
%PROCESSOR_REVISION% System Returns the revision number of the processor. 
%PROMPT% Local Returns the command prompt settings for the current interpreter. Generated by Cmd.exe.
%RANDOM% System Returns a random decimal number between 0 and 32767. Generated by Cmd.exe.
%SYSTEMDRIVE% System Returns the drive containing the Windows XP root directory (that is, the system root).
%SYSTEMROOT%  System Returns the location of the Windows XP root directory.
%TEMP% and %TMP% System and User Returns the default temporary directories that are used by applications available to users who are currently logged on. Some applications require TEMP and others require TMP.
%TIME% System Returns the current time. Uses the same format as the time /t command. Generated by Cmd.exe. For more information about the time command, see Time
%USERDOMAIN% Local Returns the name of the domain that contains the user's account.
%USERNAME% Local Returns the name of the user who is currently logged on.
%USERPROFILE% Local Returns the location of the profile for the current user.
%WINDIR% System Returns the location of the operating system directory.

Wednesday, May 15, 2013

Extract Images from Word, Excel Office 2007/2010 documents

Open the document with 7-Zip (or equivalent).  Images are stored inside the file in the folder,
word/media or xl/media.

CentOS - Install VMWare Tools after kernel update

create file vmware-checktools , touch vmware-checktools , contents of file below,

#! /bin/bash
# Following lines auto-recompile VM Tools when kernel updated
 VMToolsCheckFile="/lib/modules/`uname -r`/misc/.vmware_installed"
 VMToolsVersion=`vmware-config-tools.pl --help 2>&1 | awk '$0 ~ /^VMware Tools [0-9]/ { print $3,$4 }'`
 printf "\nCurrent VM Tools version: $VMToolsVersion\n\n"
 if [[ ! -e $VMToolsCheckFile || `grep -c "$VMToolsVersion" $VMToolsCheckFile` -eq 0 ]]; then
 [ -x /usr/bin/vmware-config-tools.pl ] && \
 printf "Automatically compiling new build of VMware Tools\n\n" && \
 /usr/bin/vmware-config-tools.pl --default && \
 printf "$VMToolsVersion" > $VMToolsCheckFile && \
 rmmod pcnet32
 rmmod vmxnet
 depmod -a
 modprobe vmxnet
 fi


copy the file vmware-checktools into the directory  /etc/init.d , cp vmware-checktools /etc/init.d

change permissions on the file,  chmod 755 /etc/init.d/vmware-checktools

create symbolic link in startup directory to the script, ln -s /etc/init.d/vmware-checktools /etc/rc3.d/S09vmware-checktools

CentOS - Setup Automatic / Scheduled Reboot


in /etc/cron.d create a file called reboot , touch reboot
inside the reboot file, vi reboot , enter the following

# Reboot system once a week on Sunday at 8AM
0 8 * * Sun root /sbin/reboot

CentOS - Setup Automatic Updates


CentOS 6.X

yum install yum-cron
chkconfig yum-cron on
service yum-cron start


CentOS 7.X

yum install yum-cron
systemctl enable yum-cron.service
systemctl start yum-cron.service
Edit the /etc/yum/yum-cron.conf  , change apply-updates=yes