Tuesday, 7 January 2014

Powershell - Query Group Membership in another Domain

This in one way that I know of to search another Domain by mounting it as a drive (I'm sure there are different ways of skinning a cat but this technique would work for a number of Domains - again I'm sure there are further options to be able to the same thing!!).

## Query Group Membership ##
Import-Module ActiveDirectory

## Mount AD as a drive ##
New-PSDrive -Name OtherDomain -PSProvider ActiveDirectory -Root 'DC=other,DC=domain,DC=co,DC=uk' -Server dc1.other.domain.co.uk -Credential DOMAIN\account
cd OtherDomain:
Get-ADGroup -Filter {Name -eq "ADGroup"} |
     ForEach-Object{
          $hash = @{GroupName = $_.Name ; UserID = '' ; Member = ''}
          $_ | Get-ADGroupMember -ea 0 -recurs |
              ForEach-Object{
                   $hash.Member = $_.Name
                   $hash.UserID = $_.SamAccountName
                   New-Object psObject -Property $hash
              }
          } | sort groupname, member | Export-CSV "C:\Data\ADGroup.csv" –NoTypeInformation

Powershell - Query Group Membership

A quick script to pull a list of users from a AD group:

## Query Group Membership ##
Import-Module ActiveDirectory
Get-ADGroup -Filter {Name -eq "ADGroup"} |
     ForEach-Object{
          $hash = @{GroupName = $_.Name ; UserID = '' ; Member = ''}
          $_ | Get-ADGroupMember -ea 0 -recurs |
              ForEach-Object{
                   $hash.Member = $_.Name
                   $hash.UserID = $_.SamAccountName
                   New-Object psObject -Property $hash
              }
          } | sort groupname, member | Export-CSV "C:\Data\ADGroup.csv" –NoTypeInformation

Friday, 27 December 2013

Microsoft - SQL and anti-virus

Just read an interesting article on AV and SQL by Michael K. Campbell - short, but gets to the point. It has a link to a very useful Microsoft KB article on AV DLLs that cause SQL performance issues.


Thursday, 19 December 2013

Solaris - /tmp permissions

Had a bit of a problem when one of the guys decided to restore file to the /tmp directory instead of the original location.

The ownership changed on /tmp to the restored folders owner which had a knock on effect with some scripts.

To fix the problem the following commands were applied:

# chmod 1777 /tmp
# chown root:root /tmp

Monday, 16 December 2013

Solaris - ZFS quota

Setting up a ZFS quota:

1. Create mount point


# zfs create -o mountpoint=/mp rpool/mp

2. Set a 5Gb quota


# zfs set quota=5G rpool/mp

The mount is now created with a quota.


What happens if you now want to increase the quota?
Increasing the quota to 20Gb


# zfs set quota=20G rpool/mp


At some point you may want to get rid of the mount point and its quota

# zfs destroy rpool/mp
 

Thursday, 14 November 2013

VMware - Checking on snapshots

The backups failed one night and left a number of snapshots marooned.

(The backup process snapshots the NetApp volume, backups up the VMs, then deletes the snapshots).

To check which machines were affected I created and ran a Powershell script.

First of all I downloaded the VMware PowerCLI from here, you will need an VMware account to download.

Then opened up the PowerCLI to run the following commands:

Set-ExecutionPolicy RemoteSigned

Connect-VIServer vCenterServerName

get-vm | get-snapshot | format-list

This produces quite an in depth list of information, but a little too much as all I'm after is the name of machines with snapshots so I can check them for the backup snapshot. The date and description (as the backup names them as "SMVI Snapshot generated for.......")

Format list will give you the following objects:
Description
Created
Quiesced
PowerState
VM
VMId
Parent
ParentSnapshotId
ParentSnapshot
Children
SizeMB
IsCurrent
IsReplaySupported
ExtensionData
Id
Name
Uid

So my actual query was this which ends with an output option to a text file:

get-vm | get-snapshot | format-list vm,date,description | out-file c:\snapshot.txt

If you want to narrow your search down to a specific container as listed in "VMs and Templates", for example "Citrix" where all your Citrix servers are collected then amend the "get-vm" part of the query:

get-vm -location ”Citrix” | get-snapshot | format-list vm,date,description | out-file c:\snapshot.txt

 







Thursday, 7 November 2013

VMware - vSphere DB queries

Looking for who kicked off a snapshot sometime in the past?

VMware KB2009075 gives you an idea on how to find out.

Will post more once I have played around with it a bit longer!

UPDATE - 14th November 2013

My amended query from the VMware default (as I'm looking for actual 'user' accounts and not system) is.

select task_id, parent_task_id, start_time, username, complete_time, entity_name, descriptionid, complete_state
from VPX_TASK
where USERNAME != ''
and USERNAME NOT IN ('DOMAIN\backup','DOMAIN\anotherservice')


I'm looking at narrowing the search down to a date which will require further investigation. 
Sites that might help with that are:
http://www.w3schools.com/