Showing posts with label host. Show all posts
Showing posts with label host. Show all posts

Thursday, May 5, 2016

VMware: Powershell Query each ESX Hosts Syslog


This query will report each host and its current Syslog

get-vmhost | select Name,@{Name="SysLog"; Expression={(get-vmhostsyslogserver $_.name)}} | FL

Saturday, August 23, 2014

Powershell - get all host files on domain.


Purpose: This script will search AD for Window computers and attempted to connect to each one. Then it will read the contents of the host file and write them to a csv file.

Note: This will take a while to run unless someone wants to make it multithreaded.
I just wrote this so there may need to be some bug fixes but in general it seemed to work.

#Read all host files and write to CSV file


Import-Module ActiveDirectory

$PATH = "c:\temp\hostfiles.csv"


   $myCol = @()
   
$AllComputers = Get-ADComputer -Filter {OperatingSystem -Like "Windows*"} -Property * | Select -Expand Name

foreach ($Computer in $AllComputers){
$i++

Write-Progress -activity "Scanning Machine $Computer " -status "Scanned: $i of $($AllComputers.Count)" -percentComplete (($i / $AllComputers.Count)  * 100)
 Get-Content -Path "\\$Computer\c$\windows\system32\drivers\etc\hosts" |             
 where {!$_.StartsWith("#")} |            
 foreach {            
  if ($_ -ne ""){            
  $data = $_ -split " ",2            
  $Hosts = New-Object -TypeName PSObject -Property @{            
     Host = $Computer
  IPAddress = $data[0].Trim()   
  Node = $data[1].Trim()            
              
   }            
  } 
  $myCol += $Hosts
 }    
 $myCol |Select Host,Node,IPAddress| Export-Csv -Path $PATH -NoTypeInformation
}




Monday, October 14, 2013

Powershell: Add NFS Exports to ESXi Hosts

Purpose:  Batch add all NFS exports to all ESXi hosts listed in $HostsToAddNFS variable.

#Add all ESXi Hosts names
$HostsToAddNFS = "hostname1","hostname2"

foreach ($Current_Host in $HostsToAddNFS )

{
connect-viserver $Current_Host
#add all NFS exports here
New-Datastore -Nfs -Name Volume1 -Path "/vol/volume1" -NfsHost x.x.x.x
New-Datastore -Nfs -Name Volume2 -Path "/vol/volume2" -NfsHost x.x.x.x


}

Powershell: Microsoft Graph to add new roles to application registration

PowerShell Script Bulk add new roles to application registration in azure. Update $roles with ,Us...