vCenter ortamında VM makineleri kim oluşturdu.

Selamlar çok detaya gerek yok zaten power shell komutu içinde gerekli açıkalamalar mevcut kolay gelsin. Connect-VIServer -server "vcent...


Selamlar çok detaya gerek yok zaten power shell komutu içinde gerekli açıkalamalar mevcut kolay gelsin.

Connect-VIServer -server "vcenter.firmaismi.local" 

# hacı ağbi bu script önce senin vCenter ortamına bağlyanıyor sonrasında ise Tüm Vm makinlerin hangi user ile oluşturulduğunu listeliyor.

# üsteki vcenter.firmaismi.local alanı sizin kendi ortamınız olacak.

if (-not (Get-PSSnapin VMware.VimAutomation.Core -ErrorAction SilentlyContinue)) {

   Add-PSSnapin VMware.VimAutomation.Core

}

if (-not (Get-PSSnapin Quest.ActiveRoles.ADManagement -ErrorAction SilentlyContinue)) {

   Add-PSSnapin Quest.ActiveRoles.ADManagement

}

 

$VMs = Get-VM | Sort Name

$VM = $VMs | Select -First 1

If (-not $vm.CustomFields.ContainsKey("CreatedBy")) {

   Write-Host "Creating CreatedBy Custom field for all VM's"

   New-CustomAttribute -TargetType VirtualMachine -Name CreatedBy | Out-Null

}

If (-not $vm.CustomFields.ContainsKey("CreatedOn")) {

   Write-Host "Creating CreatedOn Custom field for all VM's"

   New-CustomAttribute -TargetType VirtualMachine -Name CreatedOn | Out-Null

}

Foreach ($VM in $VMs){

   If ($vm.CustomFields["CreatedBy"] -eq $null -or $vm.CustomFields["CreatedBy"] -eq ""){

      Write-Host "Finding creator for $vm"

      $Event = $VM | Get-VIEvent -Types Info | Where { $_.Gettype().Name -eq "VmBeingDeployedEvent" -or $_.Gettype().Name -eq "VmCreatedEvent" -or $_.Gettype().Name -eq "VmRegisteredEvent" -or $_.Gettype().Name -eq "VmClonedEvent"}

      If (($Event | Measure-Object).Count -eq 0){

         $User = "Unknown"

         $Created = "Unknown"

      } Else {

         If ($Event.Username -eq "" -or $Event.Username -eq $null) {

            $User = "Unknown"

         } Else {

            $User = (Get-QADUser -Identity $Event.Username).DisplayName

            if ($User -eq $null -or $User -eq ""){

               $User = $Event.Username

            }

            $Created = $Event.CreatedTime

         }

      }

      Write "Adding info to $($VM.Name)"

      Write-Host -ForegroundColor Yellow "CreatedBy $User"

      $VM | Set-CustomField -Name "CreatedBy" -Value $User | Out-Null

      Write-Host -ForegroundColor Yellow "CreatedOn $Created"

      $VM | Set-CustomField -Name "CreatedOn" -Value $Created | Out-Null

   }

}

Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content