Hi, I am trying to run a powershell scripts but the problem is none of them will run. When I start the powershell, I get the following error message
Add-PSSnapin : Cannot add Windows PowerShell snap-in VMware.VimAutomation.Core
because it is already added. Verify the name of the snap-in and try again.
At C:\WINDOWS\system32\WindowsPowerShell\v1.0\profile.ps1:1 char:13
+ Add-PSSnapin <<<< VMware.VimAutomation.Core
+ CategoryInfo : InvalidArgument: (VMware.VimAutomation.Core:Stri
ng) [Add-PSSnapin], PSArgumentException
+ FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.Ad
dPSSnapinCommand
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
After that, I run this script
# Report VMs created per month.
# Before you begin run Alan's "Who Created that VM?" script.
# http://www.virtu-al.net/2010/02/23/who-created-that-vm/
function Get-VMCreationReport {
Get-VM | Group {
if ($_.CustomFields["CreatedOn"] -as [DateTime] -ne $null) {
"{0:Y}" -f [DateTime]$_.CustomFields["CreatedOn"]
} else {
"Unknown"
}
}
}
# To create a CSV of this stuff try:
# Get-VMCreationReport | select Count, Name, { $_.Group -as [String] } |
# export-csv c:\report.csv -NoTypeInformation
----------------------------------------------------------------------------------------------------------------------------------------------------
The above mentioned script can be found at - http://blogs.vmware.com/vipowershell/2010/03/find-out-how-many-vms-youre-creating-a-month-with-this-simple-script.html
Once I run that script here nothing happens I ran few other script also and I am getting the same error message
Security Warning
Run only scripts that you trust. While scripts from the Internet can be useful, this script can potentially harm your
computer. Do you want to run C:\Documents and Settings\vcpguy\Desktop\question\Get-VMCreationReport.ps1?
[D] Do not run [R] Run once [S] Suspend [?] Help (default is "D"): r
[vSphere PowerCLI] C:\Documents and Settings\vcpguy\Desktop\question>
Any idea what is going on here ?