Posts

Showing posts from September, 2014

Powershell: get free disk space from computers listed in text file. using Job

Purpose: This script will search a list of computers and report their c drives total and free space into a text file that can be imported into excel.

This is my first time using jobs to speed up the process of gathering the info so there could be a better way of doing this but this seems to work just fine.

cls #Get free disk space code from here. #http://www.codeproject.com/Articles/757946/Retrieve-Disk-Space-of-Remote-Computers-using-Powe $Global:Servers = Get-Content "C:\temp\computers.txt" $Global:ReportPath = "C:\temp\freediskspace.txt" $scriptblock = { param($server) $ConvertToGB = (1024 * 1024 * 1024) $pingResult = Test-Connection -count 1 -ErrorAction SilentlyContinue $server | select IPV4Address $disk = Get-WmiObject Win32_LogicalDisk -ComputerName $Server -Filter "DeviceID='C:'" | Select-Object Size,FreeSpace $values = @() if($Error){ if( $Error -like "*Access is denied*"){…

Netapp Busy Lun

Purpose - Find busy lun on a netapp filer running in 7mode

snap list Volume1
Volume Volume1
working...

  %/used       %/total  date          name
----------  ----------  ------------  --------
  0% ( 0%)    0% ( 0%)  Sep 11 16:31  netapp(0135052001)_mirror_computer.336 (snapmirror)
 16% (16%)   14% (14%)  Sep 09 07:42  sqlsnap__computer_09-09-2012_07.30.29__weekly (busy,LUNs)


lun snap usage -s computer sqlsnap__computer_09-09-2012_07.30.29__weekly


You need to delete the following LUNs before deleting the snapshot
        /vol/computer/{dc5a1359-317d-47cd-a408-3dd99ec4059c}.rws

You need to delete the following snapshots before deleting the snapshot
        Snapshot - netapp(0135052001)_mirror_computer.336

PowerShell: One liner get distinguishedname for all user accounts in text file

One liner to get users from a text file and create a report of distinguishedname. You need the activedirectory module imported to run.

import-module activedirectory

gc "C:\temp\serviceaccounts.txt" | Foreach-Object {Get-ADUser -filter {CN -like $_} -Properties *} | select Name, SAMAccountName, distinguishedname | export-csv -path c:\temp\test.csv