$MyCommand={ #Decalre Array $MyArray=@() #Get List of Drives $MyDrives=Get-WmiObject Win32_LogicalDisk | Where{($_.Size -ne $Null) -and ($_.DeviceID -ne "C:")} | Select -ExpandProperty DeviceID #If Drives Exists If($MyDrives -ne $Null){ #Loop Through Drive Foreach($Drive in $MyDrives){ #Decalre Array $MyData=@() #Gets ACL on Drive $MyData=get-acl $Drive #Loop Through Users / Groups Searching for Match of Everyone Foreach($Item in $MyData.Access.IdentityReference){ #If Finds Add to Array or Else If($Item -like "*Everyone*"){ $MyArray+="$Env:Computername - $Drive - $Item - Failed Check" }Else{ $MyArray+="$Env:Computername - $Drive - $Item - Passed Check" } } } #Returns Data Return $MyArray }Else{ #If No Spare Drives Found Return "$Env:Computername - No Spare Drives" } } #========================================================== # Command to Query Active Directory for Enabled Systems #========================================================== $Computers=Get-ADComputer -properties * -Filter * | Where{($_.Operatingsystem -like "Windows*") -and ($_.Enabled -eq $True)} | Select -ExpandProperty Name #Makes all Systems Upper CASE (I Like it Like that) $MyCAPComputers=$Computers.ToUpper() #==================================================================== # Command to Check for Systems online that respond to WinRM #==================================================================== #Declare Array For Passing Systems $MyComputersPassWinRM=@() Foreach ($Comp in $MyCAPComputers){ if ((Test-Connection -ErrorAction SilentlyContinue –ComputerName $Comp –Quiet –Count 1) –and ((Invoke-Command -ErrorAction SilentlyContinue –ComputerName $comp –ScriptBlock { 1 }) –eq 1)){ $MyComputersPassWinRM+=$Comp } } #==================================================================== # Command to run against all systems that passed WinRM test :) #==================================================================== Invoke-Command $MyComputersPassWinRM -ScriptBlock $MyCommand | Tee-Object C:\temp\Secondary-Hard-Drives.txt