I'm trying to configure the Application Pool of WsusPool, on a MS WSUS setup, to raise the Failure Rapid-Fail Protection Interval from 5 minutes to 30 minutes as an administrator using PowerShell.
I'm able to get the setting using
Install-WindowsFeature Web-Mgmt-Console
Import-Module WebAdministration
$WsusPool = Get-Item IIS:\AppPools\WsusPool\
$WsusPool.failure.rapidFailProtectionInterval
Days : 0
Hours : 0
Minutes : 5
Seconds : 0
Milliseconds : 0
Ticks : 3000000000
TotalDays : 0.00347222222222222
TotalHours : 0.0833333333333333
TotalMinutes : 5
TotalSeconds : 300
TotalMilliseconds : 300000
But I get an error when I try save a change to the value
$WsusPool.failure.rapidFailProtectionInterval = New-TimeSpan -Minutes 30
$WsusPool | Set-Item
Set-Item : Specified cast is not valid.
At line:1 char:13
+ $WsusPool | Set-Item
+ ~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-Item], InvalidCastException
+ FullyQualifiedErrorId : path,Microsoft.PowerShell.Commands.SetItemCommand
Some data of the system:
Version of PowerShell:
PS C:\Windows\system32> $PSVersionTable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
5 1 17763 1490
Operating system:
PS C:\Windows\system32> Get-CimInstance Win32_OperatingSystem | Select-Object Caption, Version, ServicePackMajorVersion, OSArchitecture, WindowsDirectory
Caption : Microsoft Windows Server 2019 Standard
Version : 10.0.17763
ServicePackMajorVersion : 0
OSArchitecture : 64-bit
WindowsDirectory : C:\Windows
You can use Set-WebConfigurationProperty like this
Set-WebConfigurationProperty '//*[#name="WsusPool"]//failure' -Name rapidFailProtectionInterval -Value (New-TimeSpan -Minutes 30)
Here is a very helpful page on the subject
I know this is already answered but I had to dig deep in further and found this link where Michael Felkin has put together extensive property settings for IIS which I found marvelous. Kudo to him for doing that...
You can find all that info here
Here is the shorter version of that I used:
$appPool = New-Item "IIS:\AppPools\MyAppPools" -Force
$appPool.failure.rapidFailProtection = "False"
$appPool | set-item
Keep in mind that the last line is crucial here in order to set the changes.
Hope, someone will find it helpful! :)
Related
I'm working on a simple cleanup script for work which should include gpupdate. What I want to do is run gpupdate and capture the output or run it in another window and keep the current window on top. I've tried multiple different ways to run gpupdate.exe (including using WSH with the different focus options) but it always pops up in front of the current PowerShell window. PS commandlet Invoke-GPUpdate presents an error "Access is denied" so that doesn't seem to be a usable solution. I'm currently trying to call the ProcessGPUpdate API but I must have something wrong with my code. I don't really like this solution anyway as it doesn't look like it will give feedback/progress.
Reference API: https://learn.microsoft.com/en-us/previous-versions/windows/desktop/wmi_v2/class-library/remotegpupdate-processgpupdate-method-string-boolean-boolean-boolean-boolean-uint32-string-microsoft-grouppolicy
My current non-working code
Add-Type '#
using Microsoft.GroupPolicy;
public static void ProcessGPUpdate(
string Computer,
bool force,
bool boot,
bool logoff,
bool sync,
uint delayInMinutes,
string target
)
'#
I'm open to suggestions on how to accomplish this. Currently, I'm considering running gpupdate minimized.
Edit:
Added command output as requested
PS H:\> $gpupdate = Start-Job -ScriptBlock { gpupdate.exe 2>$1 }
PS H:\> get-job
Id Name PSJobTypeName State HasMoreData
Location Command
-- ---- ------------- ----- -----------
-------- -------
1 Job1 BackgroundJob Failed False
localhost gpupdate.exe 2>$1
PS H:\> Receive-Job -Name Job1
[localhost] The background process reported an error with the following
message: .
+ CategoryInfo : OpenError: (localhost:String) [],
PSRemotingTransportException
+ FullyQualifiedErrorId : 2100,PSSessionStateBroken
PS H:\> $gpupdate = Start-Job -ScriptBlock { gpupdate.exe 2>$1 } -Name
gpupdate
PS H:\> Receive-Job -Name gpupdate
[localhost] The background process reported an error with the following
message: .
+ CategoryInfo : OpenError: (localhost:String) [],
PSRemotingTransportException
+ FullyQualifiedErrorId : 2100,PSSessionStateBroken
PS H:\> $gpupdate = Start-Job -ScriptBlock { & "gpupdate.exe 2>$1" } -Name
gpupdate
PS H:\> Receive-Job -Name gpupdate
[localhost] The background process reported an error with the following
message: .
+ CategoryInfo : OpenError: (localhost:String) [],
PSRemotingTransportException
+ FullyQualifiedErrorId : 2100,PSSessionStateBroken
[localhost] The background process reported an error with the following
message: .
+ CategoryInfo : OpenError: (localhost:String) [],
PSRemotingTransportException
+ FullyQualifiedErrorId : 2100,PSSessionStateBroken
PS H:\> get-job
Id Name PSJobTypeName State HasMoreData
Location Command
-- ---- ------------- ----- -----------
-------- -------
1 Job1 BackgroundJob Failed False
localhost gpupdate.exe 2>$1
3 gpupdate BackgroundJob Failed False
localhost gpupdate.exe 2>$1
5 gpupdate BackgroundJob Failed False
localhost & "gpupdate.exe 2>$1"
We have moved our system alerting over to SCOM 2012 and receive heartbeat alerts when servers go offline. Presently there are approximately 750 servers in the vDC that I am managing. The SCOM 2012 server is in a different untrusted domain.
I have one working script where it puts the servers in Maintenance mode, but its run serially and takes about 40 minutes to put nearly 400 servers in Maintenance Mode. This is a workable solution, but I would like to use the foreach -parallel command to speed it up.
I have my workflow (to use the foreach -parallel command) created and placed in one of the default PowerShell Module locations on the Source and Destination Machines. I've tested the set of commands outside of the workflow on the SCOM server and it runs successfully. When I try to run the command remotely via an Invoke-command, the SCOM commands come back as being unrecognized.
#Get Date for usage in Connection Name
$Date = Get-Date -Format HHmmsss
#combine Name with Date to uniquify
$name = "ScomMM" + $Date
#Collect Servers from WSUS Server
[reflection.assembly]::LoadWithPartialName("Microsoft.Updateservices.Administration") | out-null
$WSUS = [Microsoft.updateservices.administration.adminproxy]::Getupdateserver("ServerName",$false,8530);
$TS = $wsus.getcomputertargetgroups() | ? {($_.name -eq "Group1") -or ($_.Name -eq "Group2")}
$computers = $TS.getcomputertargets() | Select-Object FullDomainName
#Setup Trusted host
invoke-Command -ScriptBlock {(winrm.cmd s winrm/config/client '#{TrustedHosts="*PublicIPAddress*"}')}
Enable-PSRemoting -Force
#Credentials stored in a file
$username = "username"
$password = get-content 'Path' | convertto-securestring
$creds = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $username,$password
$session = new-PSSession -ComputerName "IPAddress" -Credential $creds -Name $name
#SCOM Commands Module
Import-Module OperationsManager
#Workflow
Import-Module Set-MM
#Run the command remotely
Invoke-Command -Session $session -ScriptBlock {
Import-Module -Name Set-MM
Set-MM -computers $using:computers
}
#Workflow - Stored at C:\Windows\System32\WindowsPowerShell\v1.0\Modules\Set-MM\Set-MM.psm1
Workflow Set-MM
{
Param($computers)
Foreach -Parallel($computer in $computers)
{
Get-SCOMClassInstance -Name $computers.FullDomainName | Start-SCOMMaintenanceMode -EndTime (Get-Date).AddMinutes(6) -Reason PlannedOperatingSystemReconfiguration
}
}
At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\Set-MM\Set-MM.psm1:6 char:3
+ Get-SCOMClassInstance -Name $computers.FullDomainName | Start ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Cannot find the 'Get-SCOMClassInstance' command. If this command is defined as a workflow, ensure it is
defined before the workflow that calls it. If it is a command intended to run directly within Windows
PowerShell (or is not available on this system), place it in an InlineScript: 'InlineScript {
Get-SCOMClassInstance }'
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : CommandNotFound
+ PSComputerName : IPAddress
The term 'Set-MM' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
+ CategoryInfo : ObjectNotFound: (Set-MM:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
+ PSComputerName : IPAddress
Get-PSSession | Remove-PSSession
If I use an Inlinescript on the script inside the foreach -Parallel
InlineScript{Get-SCOMClassInstance -Name $Using:computers.FullDomainName | Start-SCOMMaintenanceMode -EndTime (Get-Date).AddMinutes(6) -Reason PlannedOperatingSystemReconfiguration}
I get this for each computer that is attempting to get processed in the workflow:
The term 'Get-SCOMClassInstance' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
+ CategoryInfo : ObjectNotFound: (Get-SCOMClassInstance:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
+ PSComputerName : ServerName
I've got an script that lists files located under C:\ on a list of remote servers:
$Servers=Get-ADComputer -SearchBase $TerminalServersOU -Filter '*' | Sort-Object Name | Select -Exp Name
foreach ($Server in $Servers) {
$Server
#Check first if the terminal server is on
if (Test-Connection $Server -quiet) {
Invoke-Command -ComputerName $Server {
$output=dir C:\
}
}
else {
"`n$Server is disconnected"
}
The script works perfectly fine on all servers except for one called "UKBTH05CTX03". When the script runs on this server, it crashes and never finishes:
UKBTH05CTX01
UKBTH05CTX01 is disconnected
UKBTH05CTX02
Directory: C:\
Mode LastWriteTime Length Name PSComputerName
---- ------------- ------ ---- --------------
d---- 11/09/2014 23:00 inetpub ukbth05ctx02
d---- 11/09/2014 23:00 log ukbth05ctx02
d---- 14/07/2009 04:20 PerfLogs ukbth05ctx02
d-r-- 16/07/2015 15:15 Program Files ukbth05ctx02
d-r-- 15/09/2015 13:01 Program Files (x86) ukbth05ctx02
UKBTH05CTX03
Provider load failure
+ CategoryInfo : InvalidOperation: (:) [Get-WmiObject], ManagementException
+ FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
Provider load failure
+ CategoryInfo : InvalidOperation: (:) [Get-WmiObject], ManagementException
+ FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
d---- 05/10/2014 15:18 inetpub ukbth05ctx03
Provider load failure
+ CategoryInfo : InvalidOperation: (:) [Get-WmiObject], ManagementException
+ FullyQualifiedErrorId : Get WMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
I need to be able to show a message like "the script crashed on this server" and finish its execution. It is very important for me to finish its execution and know why it crashed. I don't know how to do it in PowerShell so I am looking for advise.
Thanks to all.
You should use a try/catch block to trap the error, something like this:
$Servers=Get-ADComputer -SearchBase $TerminalServersOU -Filter '*' | Sort-Object Name | Select -Exp Name
foreach ($Server in $Servers) {
$Server
#Check first if the terminal server is on
if (Test-Connection $Server -quiet) {
try
{
Invoke-Command -ComputerName $Server {
$output=dir C:\
}
}
catch
{
Write-Host "the script crashed on server: $server"
}
}
else {
"`n$Server is disconnected"
}
You could get more advanced error handling and actually return back the error received as well if needed, have a look here for more info:
Try Catch Finally and error handling in PowerShell
Pretty sure Test-Connection uses wmi to get Win32_PingStatus. Since you see lots of wmi errors, expand a Try...Catch to include that too.
If all else fails, set $ErrorActionPreference = 'SilentlyContinue' right at the start, and you might at least get some visibility on what is going on to help isolate the issue.
I like to know if there is a way to use PowerShell with WMI to set the MSNdis_currentPacketFilter
PS > Get-WmiObject -class "MSNdis_CurrentPacketFilter" -NameSpace "root\WMI" -Filter "InstanceName='Intel(R) Ethernet Server Adapter I350-T2'"
__GENUS : 2
__CLASS : MSNdis_CurrentPacketFilter
__SUPERCLASS : MSNdis
__DYNASTY : MSNdis
__RELPATH : MSNdis_CurrentPacketFilter.InstanceName="Intel(R) Ethernet Server Adapter I350-T2"
__PROPERTY_COUNT : 3
__DERIVATION : {MSNdis}
__SERVER : HYPERV88
__NAMESPACE : root\WMI
__PATH : \\HYPERV88\root\WMI:MSNdis_CurrentPacketFilter.InstanceName="Intel(R) Ethernet Server Adapter
I350-T2"
Active : True
InstanceName : Intel(R) Ethernet Server Adapter I350-T2
NdisCurrentPacketFilter : 15
PSComputerName : HYPERV88
And I would like to change the NdisCurrentPacketFilter value from 15 to 47.
I tried
Set-WMIInstance -Path ... -Arguments #{NdisCurrentPacketFilter=47}
But, got error. Thanks in advance!
===== added 04/17/2015
Here were the commands I tried:
$p=$(Get-WmiObject -class "MSNdis_CurrentPacketFilter" -NameSpace "root\WMI" -Filter "InstanceName='Intel(R) Ethernet Server Adapter I350-T2'").__Path
Write-Host $p
\\HYPERV88\root\WMI:MSNdis_CurrentPacketFilter.InstanceName="Intel(R) Ethernet Server Adapter I350-T2"
Set-WmiInstance -Path $p -Arguments #{NdisCurrentPacketFilter=47}
and error (not sure why it said command not found, but command was valid)
Set-WmiInstance : Not found
At line:1 char:1
+ Set-WmiInstance -Path $p -Arguments #{NdisCurrentPacketFilter=47}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Set-WmiInstance], ManagementException
+ FullyQualifiedErrorId : SetWMIManagementException,Microsoft.PowerShell.Commands.SetWmiInstance
And I tried this:
$o = Get-WmiObject -class "MSNdis_CurrentPacketFilter" -NameSpace "root\WMI" -Filter "InstanceName='Intel(R) Ethernet Server Adapter I350-T2'"
Write-Host $o
\\HYPERV88\root\WMI:MSNdis_CurrentPacketFilter.InstanceName="Intel(R) Ethernet Server Adapter I350-T2"
Set-WMIInstance -class "MSNdis_CurrentPacketFilter" -InputObject $o -Arguments #{NdisCurrentPacketFilter=47}
Set-WmiInstance : Parameter set cannot be resolved using the specified named parameters.
At line:1 char:1
+ Set-WMIInstance -class "MSNdis_CurrentPacketFilter" -InputObject $o -Arguments # ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-WmiInstance], ParameterBindingException
+ FullyQualifiedErrorId : AmbiguousParameterSet,Microsoft.PowerShell.Commands.SetWmiInstance
I think you are having this issue as according to scriptinternals that value is read-only.
NdisCurrentPacketFilter
Data type: integer/usint32
Access type: Read-only
I found similar information here as well. You should have wrote your error here as well. It might have added context to your issue and it is a best practice when asking questions.
Disclaimer: I know nothing about the class. Just wanted to see if anyone posted details of the class parameters.
Invoke-VMScript
Object reference not set to an instance of an object.
Which ultimately has come from :
VMware.VimAutomation.ViCore.Impl.V1.VixHelper.GetVixVersion()
On my machine, Invoke-VMScript fails when pointing at a VMGuest whose operating system is a flavor of Linux.
* Another developer is able to run this script without problems.
* He and I have matched PowerCLI and Vix versions.
* It is not an authentication problem
** I can go to his machine, use my windows credentials and the script runs
** He can come to my machine, use his windows credentials and the script throws
C:\run_a_bash_script.ps1 :
$my_fullname_vmIpChangeLin_ps1 = ( $MyInvocation.MyCommand.Definition )
$my_dir_vmIpChangeLin_ps1 = ( Split-Path $my_fullname_vmIpChangeLin_ps1 )
import-module "$( $my_dir_vmIpChangeLin_ps1 )\libs\ooooops\ooooops.psm1" -force
Set-StrictMode -Version:Latest
$GLOBAL:ErrorActionPreference = "Stop"
Add-PSSnapin VMware.VimAutomation.Core
. "$( $my_dir_vmIpChangeLin_ps1 )\libs\Initialize-PowerCLIEnvironment.ps1"
[string]$repoServer = <# VCenter FQDN #>
[string]$repoUser = <# AD username #>
[string]$repoPassword = <# password #>
[string]$vmName = <# vm logical name #>
[string]$vmUser = <# username on linux machine #>
[string]$vmPassword = <# password #>
# set to match the working powercli configuration
$null = ( Set-PowerCLIConfiguration -DefaultVIServerMode:Multiple -ProxyPolicy:UseSystemProxy -DisplayDeprecationWarnings:$true -InvalidCertificateAction:Ignore -Confirm:$false )
Connect-VIServer -Server $repoServer -User $repoUser -Password $repoPassword -WarningAction:SilentlyContinue
$script = "ls"
try
{
Invoke-VMScript -VM $vmName -ScriptText $script -GuestUser $vmUser -GuestPassword $vmPassword -Confirm:$false | Select -ExpandProperty ScriptOutput
}
catch
{
$desc = (ooooops_describe_error -obj:$_)
write-host $desc
}
Running the script :
PS c:\> C:\run_a_bash_script.ps1
Script Results :
Name Port User
---- ---- ----
<# VCenter FQDN #> 443 <# AD username #>
========ERROR SUMMARY=========================================================================================
1/14/2014 4:30:22 PM Invoke-VMScript Object reference not set to an instance of an object.
Object reference not set to an instance of an object.
NotSpecified: (:) [Invoke-VMScript], ViError
at <ScriptBlock>, C:\projects\github\nodeVM\scripts\powershell\vmIpChangeLin.ps1: line 20
VALUE_IS_NULL
at VMware.VimAutomation.ViCore.Impl.V1.VixHelper.GetVixVersion()
at VMware.VimAutomation.ViCore.Impl.V1.VixHelper.TryValidateVixVersion()
at VMware.VimAutomation.ViCore.Impl.V1.Service.VmGuestServiceImpl.<>c__DisplayClassc.<RunScriptInGuest>b__b(ClientSideTask , Object )
at VMware.VimAutomation.Sdk.Util10.Task.ClientSideTaskImpl.ThreadProc(Object obj)
At C:\projects\github\nodeVM\scripts\powershell\vmIpChangeLin.ps1:20 char:5
+ Invoke-VMScript -VM $vmName -ScriptText $script -GuestUser $vmUser -GuestPas ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
==============================================================================================================
BEGIN---> describe_error_briefly
BEGIN---> exception
exception =[NULL]
END---> exception
BEGIN---> run_time_exception
is a runtime exception? =[NO]
END---> run_time_exception
BEGIN---> error_record
CategoryInfo =[NotSpecified: (:) [Invoke-VMScript], ViError]
ErrorDetails =[VALUE_IS_NULL]
FullyQualifiedErrorId =[Client20_ClientSideTaskImpl_ThreadProc_UnhandledException,VMware.VimAutomation.ViCore.Cmdlets.Commands.InvokeVmScript]
ScriptStackTrace =[at <ScriptBlock>, C:\projects\github\nodeVM\scripts\powershell\vmIpChangeLin.ps1: line 20]
TargetObject =[VALUE_IS_NULL]
BEGIN---> exception
Data =[System.Collections.ListDictionaryInternal]
Message =[1/14/2014 4:30:22 PM Invoke-VMScript Object reference not set to an instance of an object. ]
Source =[VALUE_IS_NULL]
StackTrace =[VALUE_IS_NULL]
TargetSite =[VALUE_IS_NULL]
BEGIN---> exception
Data =[System.Collections.ListDictionaryInternal]
Message =[Object reference not set to an instance of an object.]
Source =[VMware.VimAutomation.ViCore.Impl]
StackTrace =[ at VMware.VimAutomation.ViCore.Impl.V1.VixHelper.GetVixVersion()
| at VMware.VimAutomation.ViCore.Impl.V1.VixHelper.TryValidateVixVersion()
| at VMware.VimAutomation.ViCore.Impl.V1.Service.VmGuestServiceImpl.<>c__DisplayClassc.<RunScriptInGuest>b__b(ClientSideTask , Object )
| at VMware.VimAutomation.Sdk.Util10.Task.ClientSideTaskImpl.ThreadProc(Object obj)]
TargetSite =[System.String GetVixVersion()]
BEGIN---> exception
exception =[NULL]
END---> exception
END---> exception
END---> exception
BEGIN---> invocation_info
PositionMessage =[At C:\projects\github\nodeVM\scripts\powershell\vmIpChangeLin.ps1:20 char:5
|+ Invoke-VMScript -VM $vmName -ScriptText $script -GuestUser $vmUser -GuestPas ...
|+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~]
END---> invocation_info
END---> error_record
END---> describe_error_briefly
The method does not seem to exist
both of these return $null
write-host ( [VMware.VimAutomation.ViCore.Impl.V1.VixHelper] | Get-Member -MemberType:All | Where-Object { $_.Name -like "%ersion%" } | Format-Table | Out-String )
and
write-host ( [VMware.VimAutomation.ViCore.Impl.V1.VixHelper] | Get-Member -MemberType:All -Static | Where-Object { $_.Name -like "%ersion%" } | Format-Table | Out-String )
Windows Os, ControlPanel / Programs / Programs and Features
VMWare VIX 1.12.1.33347
VMWare vSphere PowerCLI 5.5.0.5836
PowerCLI Versions / Configuration
Function get_debug_info()
{
write-host "-----------Get-PowerCLIConfiguration--------------------------------------------------"
write-host ( Get-PowerCLIConfiguration | Format-List | Out-String )
write-host "-----------Get-PowerCLIVersion--------------------------------------------------"
write-host ( Get-PowerCLIVersion | Format-List | Out-String )
return $null
}
For the one that works
-----------Get-PowerCLIConfiguration--------------------------------------------------
DefaultVIServerMode : Multiple
ProxyPolicy : UseSystemProxy
DisplayDeprecationWarnings : True
InvalidCertificateAction : Ignore
WebOperationTimeoutSeconds : 300
VMConsoleWindowBrowser :
Scope : Session
DefaultVIServerMode : Multiple
ProxyPolicy :
DisplayDeprecationWarnings :
InvalidCertificateAction :
WebOperationTimeoutSeconds :
VMConsoleWindowBrowser :
Scope : User
DefaultVIServerMode : Single
ProxyPolicy :
DisplayDeprecationWarnings : True
InvalidCertificateAction : Ignore
WebOperationTimeoutSeconds :
VMConsoleWindowBrowser :
Scope : AllUsers
-----------Get-PowerCLIVersion--------------------------------------------------
Major : 5
Minor : 5
Build : 1295336
Revision : 0
Copyright : Copyright © VMware, Inc. 1998-2013
Company : VMware, Inc.
UserFriendlyVersion : VMware vSphere PowerCLI 5.5 Release 1 build 1295336
SnapinVersions : {VMWare AutoDeploy PowerCLI Component 5.5 build 1262826, VMWare ImageBuilder PowerCLI Component 5.5 build 1262826, VMware License PowerCLI Component 5.5 build 1265954, VMware VDS PowerCLI Component 5.5 build 1295334...}
For the one that does not work
-----------Get-PowerCLIConfiguration--------------------------------------------------
DefaultVIServerMode : Single
ProxyPolicy : UseSystemProxy
DisplayDeprecationWarnings : True
InvalidCertificateAction : Ignore
WebOperationTimeoutSeconds : 300
VMConsoleWindowBrowser :
Scope : Session
DefaultVIServerMode : Single
ProxyPolicy :
DisplayDeprecationWarnings :
InvalidCertificateAction :
WebOperationTimeoutSeconds :
VMConsoleWindowBrowser :
Scope : User
DefaultVIServerMode : Multiple
ProxyPolicy : UseSystemProxy
DisplayDeprecationWarnings : True
InvalidCertificateAction : Ignore
WebOperationTimeoutSeconds :
VMConsoleWindowBrowser :
Scope : AllUsers
-----------Get-PowerCLIVersion--------------------------------------------------
Major : 5
Minor : 5
Build : 1295336
Revision : 0
Copyright : Copyright © VMware, Inc. 1998-2013
Company : VMware, Inc.
UserFriendlyVersion : VMware vSphere PowerCLI 5.5 Release 1 build 1295336
SnapinVersions : {VMWare AutoDeploy PowerCLI Component 5.5 build 1262826, VMWare ImageBuilder PowerCLI Component 5.5 build 1262826, VMware License PowerCLI Component 5.5 build 1265954, VMware VDS PowerCLI Component 5.5 build 1295334...}
I had faced the same problem. My Invoke-VMScript was not working. After digging deep into it I found my vCenter server(in my case the target server) was having ipv6 configuration. I removed the ipv6 configuration and changed it to ipv4 configuration.
My issue got resolved.
As described here:
* http://www.virten.net/2013/06/run-scripts-in-linux-guests-by-using-vmware-tools/
* http://www.lucd.info/2012/01/01/will-invoke-vmscript-work/
* https://communities.vmware.com/message/2314207
The problem is that the VIX libraries are 32 bit and I was running the script using 64 bit Powershell.
On a 64 bit OS :
* Powershell 64 bit is the default
* the path to the 32 bit Powershell is : %systemroot%\syswow64\windowspowershell\v1.0\
A simple powershell statement to test if the powershell process is 32 or 64 bit:
[Environment]::Is64BitProcess