Using powershell to search for files with date and owner criteria

I recently had a requirement to search some file servers for files that were modified between 2 date ranges and then filter that output by owner.

After some googleing I came up with the following script with a commented out line that would allow a copy of those files after indexing.

———————————————————————————-

$path = Read-Host “Please enter the top-level path (eg: C:\Temp)”

$user = Read-Host “Please enter the user to be searched for (eg: DOMAIN\User)”
$dst = Read-Host “Please enter the copy destination:”

$files = Get-childitem $path -recurse |
where {$_.lastwritetime.date -gt
[datetime]::parse(“01/01/2010″) -and
$_.lastwritetime.date -lt
[datetime]::parse(“01/01/2011″)}

foreach ($file in $files){
$owner = Get-Acl $file.FullName
if ($owner.Owner -eq $user){Write-output $file.FullName >> output}
#if ($owner.Owner -eq $user){copy-item -path $file.FullName -dest $dst -force}
else {}
}

Find/Search for VMWare guests mac address on ESX 4 and ESXi 4 hosts onwards

In the past on vmware you could use the tool vmware-cmd-l to help you find the mac addresses of guests registered to vmware hosts.

You might need to do this if you have an ip address conflict or for some other reason where going through all the guests would be a time consuming and laborious process.

With ESX and ESXi version 4 onwards that command was removed, so the below ash script will allow you to either list the VM’s on a host, or if you use it with an argument it will search for a mac address or part of a mac address.

This script will allow you to search and find a mac address and tie that to a guest name. The script needs to be run on the ESX or ESXi host/s

run it from the command line like below

#./macfinder.sh   < no arguments to list all registered VM’s

or

#./macfinder.sh 00:50:56:00:00:00  < with argument to find specific or part of mac address

 

___________________________ shell script below —————————

#!/bin/ash
# searches current registered vm’s then uses that list to find macAddresses of those

# then greps output for desired mac or part of mac address

vim-cmd vmsvc/getallvms | awk ‘{print $1″:” $2}’ | grep -v Vmid > /tmp/allvms
for lines in `cat /tmp/allvms`do

id=$(echo $lines | awk -F: ‘{print $1}’)

name=$(echo $lines | awk -F: ‘{print $2}’)

mac=$(vim-cmd vmsvc/device.getdevices $id | grep macAddress)

if test $1then
echo $name $mac | grep $1

else echo $name $mac

fi

done

rm -rf /tmp/allvms

Port mirroring on nortel 5520 switch stack

Recently had cause to set this up, and although i’m familiar and comfortable doing this on cisco stuff, never had cause to do it on our nortels.

The config below is what is required on the cli – if you have access to the web interface its pretty straight forward there too.

port-mirroring mode xrxorxtx monitor-port 1/23 mirror-port-X 2/3 mirror-port-Y 2/4

According to the nortel documentation this mirrors ports 2/3 and 2/4 to port 1/23 – however in practice and looking through the bugs list the firmware we ran does not actually support monitoring 2 ports, so we ended up falling back to just the single mirror.