Wednesday, February 4, 2015

Bulkhead

Definition:  An upright wall within the hull of a ship. Particularly a watertight, load-bearing wall.

Hitting your head up against the bulkhead with ex-employees still showing up in Sharepoint?

Check out:

http://sharepointrelated.com/2012/10/11/remove-bulk-users-from-user-information-list-people-picker/

Leave a comment if you have any useful links on bulkhead removers.  If you don't know of any, keep looking.  They're out there somewhere.

Tuesday, June 10, 2014

Dead in the Water

Definition:  Not moving (used only when a vessel is afloat and neither tied up nor anchored).

Often times, you'll need to restore a production database to a development and test instance so that developers have current data for their testing.  If the database has local database users, these accounts will need to be 'fixed' so they are properly associated with the local SQL logins on this other instance.  Until these accounts are fixed, your developers will be 'Dead in the Water'.


To see the accounts that need to be fixed, execute:

sp_change_users_login 'report'

To fix the accounts, run:
exec sp_change_users_login 'UPDATE_ONE','AccountName','AccountName'


Once these accounts are fixed, your developers can "Shift Colors" and get underway!





Thursday, January 23, 2014

Sweepers, Sweepers, Man Your Brooms



Users will always have some type of home directory where they can store their data.  Often times, these directories are not deleted after a user leaves the company.

Try this short script to see if what directories are not tied to existing accounts in your Active Directory:

 foreach ($user in get-content c:\temp\users.txt)
 {if( Get-QADUser -LogonName $user ) {$user + ",exists"} else {$user +",does not exist in AD"}
         }



"Sweepers, Sweepers, man your brooms. Give the ship a good clean sweep down both fore and aft! Sweep down all lower decks, ladder backs and passageways! Dump all garbage clear of the fantail!"

Tuesday, December 10, 2013

"Time, tide and formation wait for no man......"

Often times, system problems can be attributed to an incorrect system time.

Using "w32tm.exe" you can resync your system:

w32tm.exe /resync /nowait /rediscover


To query your time settings:

w32tm.exe /query /source











Thursday, September 19, 2013

SQL Server Tip of the Day

DBAs often need to refresh database instances for developers.  In this case, you need to restore some database from a backup file.

Here are few simple commands to help with this task:


Determining what processes are using the database (Note the single quote around <database name>)

USE master
SELECT * FROM sys.sysprocesses WHERE dbid = DB_ID('<database name>')


Set database to SINGLE_USER (Note the double quotes around <database name>)

use master;
GO

ALTER DATABASE "<database name>" SET SINGLE_USER WITH ROLLBACK IMMEDIATE;

Detach database (Note the single quotes around <database name>)
EXEC sp_detach_db 'AdventureWorks2012', 'true';

Delete database (Note the doube quotes around <database name>)

use master;
    GO
      DROP DATABASE "<database name>";
        GO


        Once the database is deleted, you can use the restore GUI to restore the database using the original name.

        See database file space usage 

        USE <database name>
        GO 

        SELECT DB_NAME() AS DbName, 
        name AS FileName, 
        size/128.0 AS CurrentSizeMB,  
        size/128.0 - CAST(FILEPROPERTY(name, 'SpaceUsed') AS INT)/128.0 AS FreeSpaceMB 
        FROM sys.database_files;


        List recovery modes for all databases

        SELECT name AS [Database Name],
        recovery_model_desc AS [Recovery Model]
        FROM sys.databases
        GO

        Change dbo for a database
        EXEC sp_changedbowner '<databasename>'

        Tuesday, January 22, 2013

        Inactive ESXi NFS Mounts

        After moving an ESXi host from one site to another, I realized we didn't unmount all the NFS mounts.  Upon restarting, the original datastores were still listed but greyed out.  Clicking on "Delete" resulted in an error message.










        This is easily fixable:


        1. SSH to your host
        2. Use esxcfg-nas -d <datastore name>
        3. Reboot host


        Friday, December 21, 2012

        Simple Powershell Scripts

        qad* commands:

        You'll need to download the free PowerShell Commands for Active Directory from http://www.quest.com/

        Exchange commands:

        You may need to install the Exchange Management tools from the Exchange ISO and then run Add-PSSnapin microsoft.exchange.management.powershell.e2010



        #get home dir paths

        foreach ($user in get-content usernames.txt)
         {get-qaduser -identity $user | select homedirectory
               }

        #set home dir paths

        foreach ($user in get-content usernames.txt)
         {set-qaduser -identity $user -homedirectory "<UNC Home Dir Path>"
               }


        # Set AD company attribute and AD extension attribute #2

        foreach ($user in get-content usernames.txt)
         {set-qaduser -identity $user -company "<Company Name>" -objectAttributes @{extensionAttribute2="<text>"}
               }

         #Set AD user attributes

        foreach ($user in get-content usernames.txt)
         {
         get-qaduser -identity $user | select cn,creationdate,city,NTAccountName
               }


        #Set UPN

        foreach ($user in get-content usernames.txt)
         {set-qaduser -identity $user -userprincipalname $user@<new domain.com>
               }
              

        #Get AD user attributes 

        foreach ($user in get-content usernames.txt)
         {get-qaduser -identity $user -includeallproperties | select PrimarySMTPAddress,email,PrimarySMTPAddressSuffix,UserPrincipalName,sn,FirstName,LastName,logonName,displayname,StateOrProvince,city     }


        #Get AD computer attributes and save to .csv file

        Add-PSSnapIn -Name Quest.ActiveRoles.Admanagement
        get-qadcomputer * -sizelimit 0 -includeallproperties | select Name,ComputerName,cn,description,whenCreated,whenChanged,operatingSystem,operatingSystemServicePack,dNSHostName,ComputerRole,DnsName,DN,Type,parentcontainer,managedby,extensionattribute15 | Export-Csv "D:\temp\AllADComputerObjects.csv"

        remove-item  <Old File Path>
        copy-item “D:\temp\AllADComputerObjects.csv” <New Path>

         #Get all email addresses for all objects

        Add-PSSnapin microsoft.exchange.management.powershell.e2010
         get-mailbox * -resultsize unlimited -domaincontroller <Domain Controller> | select SamAccountName -expand EmailAddresses | Export-Csv <outpot.csv>

        Thursday, December 20, 2012

        Fixing DPM 2010 Reporting Services

        A useful function in DPM 2020 are the reporting capabilities.  You can generate reports to view recovery point status, disk/tape usage, etc.....
         
        If the reporting function doesn't work, it may be related to the account that is used in the Reporting Services configuration.  For example, if the password you set for the reporting services account doesn't meet the local password policy, reporting functionality will fail.
         
        To fix this:

        • Set valid password for Reporting Services account 
        • Name:  DPMR$<ServerName>
        •  Password:  *******
        • Verify account is in group:  DPMDBReaders$<ServerName>
        • Go to the Reporting Services Web page: 
        •  Click on DPMReports – DPMReporterDataSource
        • In the “Connect Using” section:
        • Select “Credentials stored securely in the report server”
        • Enter above username and password
        • Select “Use as Windows credentials when connecting…..
        • Click on Apply
        • Stop and start Reporting Services Instance
        • Confirm the reports are functioning
         
        • 

        Wednesday, November 28, 2012

        Round Robin


        Has your storage administrator ever contacted you saying only one path is being used by your ESXi environment?  He may have noticed this by looking at the SAN's performance and the total throughput of each path.

         






        In this case, all activity is through one of the paths while the other paths are basically idle.

        Setting a single LUN in vSphere is easy
        1. Select the host - Configuration tab - storage
        2. Right click on a datastore - select properties - Manage Paths
        3. On Path Selection, ensure it is set to Round Robin








        When building an ESXi host, you can run this command via SSH so that Round Robin is set by default:

        • esxcli nmp satp setdefaultpsp --satp VMW_SATP_ALUA --psp VMW_PSP_RR
        Note:  Make sure you have two dashes for each

        If you have multiple ESXi hosts with multiple LUNS, setting each path manually can be time consuming.  In this case, you can use powershell.  This command will look at all LUNS and set the path policy to roundrobin if it's not already set:
        • Get-ScsiLun -VmHost <ESXi Host Name> -LunType disk | Where { $_.MultipathPolicy -notlike “roundrobin“}  | Set-ScsiLun -MultipathPolicy “roundrobin"
        You can then run this command against all your hosts.

        Once everything is set to Round Robin, you and your storage administrator will be much happier as throughput will be spread across all paths.