Invoke-command takes 20-90 seconds to complete

all servers I'm testing with is server 2008r2 with powershell 4.  I have a text file with 100 servers that are online and with PS remoting enabled.
When I run this command:
# this takes about 20-30 seconds to complete
Invoke-Command
-ScriptBlock
{get-date}
-ComputerName
(gc
100servers.txt)
# this takes at least 90 seconds to complete when I set throttle to 100
Invoke-Command
-ScriptBlock
{get-date}
-ComputerName
(gc
100servers.txt)
-ThrottleLimit
100
I didn't get these delays when my local was running powershell 2 and executing against the same set of servers with PS4 on them.  PS2 only took 2-3 seconds to finish the command if all were online.  If I run the command in PS4 ISE, it seems to
work fast as well but for some reason PS4 traditional shell (not ISE) gives me these delays when working with large set of servers and increasing throttle to 100+
Sometimes you get different results if you keep running it with the same shell, but if you open a new shell with -noprofile switch then I get the same execution delays with PS4.
# I even tried skipping the different checks with sessionOption below but same results
Invoke-Command
-ScriptBlock
{get-date}
-ComputerName
(gc
100servers.txt)
-ThrottleLimit
100
-SessionOption
(New-PSSessionOption
-SkipCACheck
-SkipRevocationCheck
-SkipCNCheck)
I also tried running the same command from win8.1 with PS4 and it will hang for about 90 seconds before it spits out all the results at once.
This seems to be a problem with large number of servers of at least 50.  Works fine with small set.  Is anyone else having this problem?  I know there's other ways of running scripts in parallel, but I can't figure out why this is not working. 
I'm also using the default pssessionoption below.  I have full admin rights to all the servers.  Any suggestions?
MaximumConnectionRedirectionCount : 5
NoCompression                     : False
NoMachineProfile                  : False
ProxyAccessType                   : None
ProxyAuthentication               : Negotiate
ProxyCredential                   :
SkipCACheck                       : False
SkipCNCheck                       : False
SkipRevocationCheck               : False
OperationTimeout                  : 00:03:00
NoEncryption                      : False
UseUTF16                          : False
IncludePortInSPN                  : False
OutputBufferingMode               : None
Culture                           :
UICulture                         :
MaximumReceivedDataSizePerCommand :
MaximumReceivedObjectSize         :
ApplicationArguments              :
OpenTimeout                       : 00:03:00
CancelTimeout                     : 00:01:00
IdleTimeout                       : -00:00:00.0010000

-asjob only puts it in the background, but it still takes the same amount of time to finish.  Any other suggestions?  I want to be able to increase the throttle to at least 100 servers.  With PS2, I was able to throttle to 200 servers and
was very fast.  Not sure why PS4 is so much slower.  It seems to run better without increasing the throttle, but still slower when dealing with 100 servers compared to PS2 results.
Invoke-Command
-ScriptBlock
{get-date}
-ComputerName
(gc
100servers.txt)
-ThrottleLimit
100

Similar Messages

  • Firefox 27.0.1 takes 140 seconds to complete MS Chalkboard test

    Using the MS Chalkboard test http://ie.microsoft.com/testdrive/Performance/Chalkboard/
    on an iMac 2012, 32gb RAM, Core i7, 3.4Ghz it takes approx 140 seconds to complete the test. In Safari about 6.46 seconds, and in IE11 on Parallels VM it takes 6 seconds.
    Something seems very wrong with the responsiveness of Firefox.... Tried uninstalling and reinstalling to no avail.

    It didn't run smoothly for me, and I'm not sure the stopping positions were accurate. It kept pausing to wait for something to complete, little resizing movements here and there.
    In my regular profile with hardware acceleration of graphics disabled and lots of tabs open, it took about 68 seconds. In a new profile with no customization, it took about 34 seconds.
    I don't have a modern IE on this computer to compare, but I tested in Google Chrome 33. It was much snappier and finished in about 12.5 seconds.
    No idea what's going on with this benchmark that makes Firefox slower.

  • Invoke-command for msiexec hangs

    Hi,
    I'm running a client of Windows 8 Pro against a server of Win2012R2
    I have the following script:
      $args = "-i `"$MSIPathFile`" INSTALLDIR=`"$InstallFolderOnTargetServer`" /qn /norestart"
            LogInfo "args: $args"
            $Session = EstablishSession $TargetServer $CommonPowershellScriptPath
            try
                #Invoke-Command -session $Session -ScriptBlock{param($arguments) start-process -FilePath "msiexec.exe" -Wait $arguments } -Argument $arguments
                #winrs -r:$TargetServer msiexec.exe $arguments
                $script = {
                    #do preinstall stuff
                    [diagnostics.process]::start("c:\windows\system32\msiexec.exe", $args).WaitForExit()
                    #do follow up stuff
                invoke-command -session $Session -scriptblock $script
    When the invoke-command line is executed, I get no response - I've waited for 10 minutes!
    I've checked the event log on the server and client and there's nothing. I know the $Session variable holds a good session because it works with this elsewhere in the script. The credential used by this is a domain account that is a member of the local administrators
    group on the target server
    If I take the content of $args and run this with msiexec directly on the server then the msi silently installs in about 15 seconds.
    I have followed the instructions here in order to Enable-PsWsmanCombinedTrace (http://windowsitpro.com/blog/troubleshooting-winrm-and-powershell-remoting-part-1) but
    the only error I see is within the "Windows Remote Management\Operational" log:
    WSMan operation SignalShell failed, error code 2150858793
    I think this could be caused when I force the debugger to stop - so could be a red herring.
    This same script has worked well in the past, though that was different servers and network.
    Any suggestions as to what else I can try in order to get the MSI to install remotely?

    Not all MSIs will install unattended.  It is pretty certian a message is being shown and stoipping the install.  Check with the vendor to be sure they support full unattended installs.
    ¯\_(ツ)_/¯

  • Clear history hangs and takes quite a while to complete even when only one site is visited

    clear history hangs and takes quite a while to complete even when only one site is visited . While not a major problem it is annoying

    Hi Frank,
    Does this Release Management performance isssue occurred when you use it at first time? Do you have any setting on your TFS? Would you please tell us your TFS version? 
    If you have any repro steps, please share with us, thank you. 
    Best Regards,
    Dear Molly,
    Yes, this issue has occurred right from the beginning when we started using Release Management.
    Could you please clarify what you mean by "do you have any setting on your TFS"? As far as I know, our TFS installation is a straightforward and normal one.
    Our TFS version is TFS 2013.
    The steps to reproduce (in the simplest scenario) are as follows:
    Create a new project in Visual Studio 2013, containing one PowerShell script file. In the script file, perform a simple command such as "New-Item E:\Temp3 -itemtype directory -force".
    Perform a successful build of the project, making sure that the script file is copied to the drop folder.
    Create a vNext Component in the Release Management Client, that refers to the directory in the drop folder that contains the script file.
    Create a new vNext Release Template in the Release Management Client, containing one "Deploying using PS/DSC" action. In that action, set the PSScriptPath to the script file we created.
    Perform a new Release using the Release Template we just created. The Deploy action will take a long time, even though the script itself takes less than a second to run.
    Please let me know if you need any more information.

  • Release Management performance - Each step takes over a minute to complete

    We have set up a Release Management pipeline using vNext Release Templates with PS/DSC. We noticed that every release step takes about 1:47m to complete, whereas the actual tasks that are performed within each step (i.e. copying the component and executing
    the PowerShell script) take only a few seconds. We tested this by copying files and executing PowerShell scripts outside of Release Management.
    One of our deployments took about half an hour to complete (and should have taken only a few minutes). (I wanted to include a screenshot but got "Body text cannot contain images or links until we are able to verify your account." when trying to
    submit this question.)
    We also tested this with a minimal component, containing only one file (one PowerShell script), but even then the deployment took about 1:47m.
    Can you tell us what the reason is for this delay? What should be done in order to speed up this process?

    Hi Frank,
    Does this Release Management performance isssue occurred when you use it at first time? Do you have any setting on your TFS? Would you please tell us your TFS version? 
    If you have any repro steps, please share with us, thank you. 
    Best Regards,
    Dear Molly,
    Yes, this issue has occurred right from the beginning when we started using Release Management.
    Could you please clarify what you mean by "do you have any setting on your TFS"? As far as I know, our TFS installation is a straightforward and normal one.
    Our TFS version is TFS 2013.
    The steps to reproduce (in the simplest scenario) are as follows:
    Create a new project in Visual Studio 2013, containing one PowerShell script file. In the script file, perform a simple command such as "New-Item E:\Temp3 -itemtype directory -force".
    Perform a successful build of the project, making sure that the script file is copied to the drop folder.
    Create a vNext Component in the Release Management Client, that refers to the directory in the drop folder that contains the script file.
    Create a new vNext Release Template in the Release Management Client, containing one "Deploying using PS/DSC" action. In that action, set the PSScriptPath to the script file we created.
    Perform a new Release using the Release Template we just created. The Deploy action will take a long time, even though the script itself takes less than a second to run.
    Please let me know if you need any more information.

  • Error occurred in deployment step 'Add Solution': A timeout has occurred while invoking commands in SharePoint host process.

    Hi,
    I am deplyoing a  solution which has  custom web parts- vwp- appln pages, event receivers.
    It was working fine till last week. I was able to deploy the solution and able to see the web parts and func. was working.
    But now from the last 2 days onwards, when I tried to depoy this soution, I am getting the error
    "Error occurred in deployment step 'Add Solution': A timeout has occurred while invoking commands in SharePoint host process "
    may i know why am getting this error.
    note: my dev machine- Win Srvr 2012 - VS 2012- SP 2013 - SP D 2013 was having soem issues  with the space in C drive.
    once i have done the  index reset few months back and i started getting space in C:\ Drive is 0 bytes.
    so what my infra. team  has done is , increased the space in drive to 150 GB[ it was a  VM ].
    help is appreciated !

    What is current disk space on your drives
    Delete ULS logs and other log files from server id not needed
    could be related to ChannelOperationTimeout
    http://msdn.microsoft.com/en-us/library/ee471440(v=vs.100).aspx
    Also, don't forget to restart Visual Studio
    Goto the following regustry key: HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0\SharePointTools
    Add the following as a DWORD (wont be there by default)
    ChannelOperationTimeout
    REG_DWORD that specifies the time, in seconds, that Visual Studio waits for a SharePoint command to execute. If the command does not execute in time, a SharePointConnectionException is thrown.
    The default is 120 seconds.
    http://social.technet.microsoft.com/wiki/contents/articles/21052.como-resolver-o-erro-error-occurred-in-deployment-step-activate-features-a-timeout-has-occurred-while-invoking-commands-in-sharepoint-host-process-pt-br.aspx
    If this helped you resolve your issue, please mark it Answered

  • Error occurred in deployment step 'Activate Features': A timeout has occurred while invoking commands in SharePoint host process.

    Error 1 Error occurred in deployment step 'Activate Features': A timeout has occurred while invoking commands in SharePoint host process.
    0 0 myProjectAssetsLists
    am getting the above error when i deploy my farm solution which is actually a "farm solution import package" template.
    i am deploying this to a new site collection and once its features are activated this will provision few doc libs and splists in the targeted site.
    any help is appreciated.

    try below link:
    http://msdn.microsoft.com/en-us/library/ee471440.aspx
    http://sujeetrec.blogspot.in/2013/12/sharepoint-2010-deployment-timing-out.html
    Increase the timeout that Visual Studio waits for SharePoint to deploy a feature:
    Create: [HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0\SharePointTools] ChannelOperationTimeout DWORD
    The value is a timeout in seconds. The default is 120 (2 minutes).
    Full details on this switch and others are here:
    http://msdn.microsoft.com/en-us/library/ee471440.aspx

  • Run invoke-command on multiple machines at the same time

    Hey all so I read that if I store my New-pssession in a variable then used that in my invoke-command it would run all computers at the same time.
    $a = Get-Content "C:\Users\cody-horton\Desktop\list.txt"
    $session
    for($i=0;$i -lt $a.Length;$i++){
    if(!(Test-Connection -Cn $a[$i] -BufferSize 16 -Count 1 -ea 0 -quiet)){
    Write-Host $a[$i] -foregroundcolor red
    else{
    $session = New-PSSession $a[$i]
    Invoke-Command -Session $session -FilePath "\\My computer\C`$\Users\public\Documents\zip folder.ps1"
    What exactly am I doing wrong I just need to run this script on multiple machines at the same time.
    Thanks.
    Edit: Also what would be the best way to close all the sessions thanks.

    Hi there,
    So what I think you are doing wrong here is that you are overwriting the value in $Session everytime you executed code inside for loop. try the below:
    $a = Get-Content "C:\Users\cody-horton\Desktop\list.txt"
    $session = @() #define this as an array
    for($i=0;$i -lt $a.Length;$i++){
    if(!(Test-Connection -Cn $a[$i] -BufferSize 16 -Count 1 -ea 0 -quiet)){
    Write-Host $a[$i] -foregroundcolor red
    else{
    $session += New-PSSession $a[$i] #add the new session to the array, at the end it will be a collection of sessions
    Invoke-Command -Session $session -FilePath "\\My computer\C`$\Users\public\Documents\zip folder.ps1" #I think the above one won't work..first you need to copy the script locally on the machine and then execute it#Why this won't work because of Second-Hop Authentication
    Have put comments where I edited your code.
    Hope this helps
    Knowledge is Power{Shell}. http://dexterposh.blogspot.com/

  • My macbook pro takes 5-10 seconds to connect to my wifi

    when I gear up my computer or when I click on my safari, it takes 5-10 seconds to hook up to my wifi
    anybody have any ideas why

    Can't vouch for your setup, unknown to me, but I see my MBP take about 3-5 seconds to renegotiate its association to my home's encrypted Wi-Fi ADSL router, whereas the unencrypted base station at work completes the process much faster. I have Personal WPA2 encryption with a 128bit key and this has a direct bearing on the process.
    Since the neighbor had the vice of hooking up to my router prior to my enabling heavy duty protection, the time the Mac takes to reconnect is a necessary and unavoidable evil.

  • My restore takes 12hrs and doesn't complete, after 6.0.1

    iOS 6.0.1 upgrade reset my phone to factory settings. Now my restore takes 12hrs and doesn't complete, I have tried this twice, please help.

    The Basic Troubleshooting Steps are:
    Restart... Reset... Restore...
    iPhone Reset
    http://support.apple.com/kb/ht1430
    Try this First... You will Not Lose Any Data...
    Turn the Phone Off... ( if it isn’t already )
    Press and Hold the Sleep/Wake Button and the Home Button at the Same Time...
    Wait for the Apple logo to Appear and then Disappear...
    Usually takes about 15 - 20 Seconds... (But can take Longer...)
    Release the Buttons...
    Turn the Phone On...

  • Invoke-Command & Add-CMDistributionPoint - Certificate failure

    Hi together,
    for automatic creation of Distribution Points I am doing the following things.
    Doing this locally on the Primary Site Server as Network Access Account everything works fine.
    But when I try to do this with invoke-command on my machine with Network Access Account too, I'll get an error:
    WARNING: The self signed certificate could not be created successfully.
    What am I doing wrong?
    Here is what I am doing locally:
    Write-Host "------------------NOW Running on REMOTE Primary Site----------------" -BackgroundColor Yellow -ForegroundColor Black
    if(!(Test-Path $RemoteSCCMModule))
    Write-Error "Could not find Remote SCCM Module!"
    Exit
    Write-Debug "Importing SCCM Module..."
    Import-Module $RemoteSCCMModule -Force
    $SiteLocation = $SiteCode + ":"
    Set-Location $SiteLocation | Out-Null
    if(($BoundaryName -ne "") -and ($BoundaryName -ne " ") -and ($BoundaryName -ne $null) -and ($BoundaryName -ne $false))
    $BoundaryValue = $BoundaryStartIP + "-" + $BoundaryEndIP
    New-CMBoundary -DisplayName $BoundaryName -BoundaryType IPRange -Value $BoundaryValue
    New-CMBoundaryGroup -Name $BoundaryGroupName
    Add-CMBoundaryToGroup -BoundaryGroupName $BoundaryGroupName -BoundaryName $BoundaryName
    New-CMSiteSystemServer -ServerName $using:NewDPServer -SiteCode $using:SiteCode
    Start-Sleep -Seconds 2
    Add-CMDistributionPoint -SiteSystemServerName $NewDPServer -SiteCode $SiteCode -MinimumFreeSpaceMB $MinimumFreeDiskSpace -EnablePxeSupport -AllowRespondIncomingPxeRequest -EnableUnknownComputerSupport -ComputersUsePxePassword $PXEPassword -UserDeviceAffinity DoNotUse -PxeServerResponseDelaySeconds 5 -CertificateExpirationTimeUtc $CertExpirationDate
    Start-Sleep -Seconds 2
    Foreach($DPGroup in $NewDPServer_Groups)
    Add-CMDistributionPointToGroup -DistributionPointGroupName $DPGroup -DistributionPointName $NewDPServer
    And this is what I am doing with Invoke-Command:
    Invoke-Command -ComputerName $PrimarySiteServer -ConfigurationName Microsoft.PowerShell32 -Credential $NAACred -ScriptBlock {
    $DebugPreference = $using:DebugPreference
    Write-Host "------------------NOW Running on REMOTE Primary Site----------------" -BackgroundColor Yellow -ForegroundColor Black
    Write-Debug "Importing SCCM Module..."
    Import-Module $using:RemoteSCCMModule -Force
    $SiteLocation = $using:SiteCode + ":"
    Set-Location $SiteLocation | Out-Null
    if(($using:BoundaryName -ne "") -and ($using:BoundaryName -ne " ") -and ($using:BoundaryName -ne $null) -and ($using:BoundaryName -ne $false))
    $BoundaryValue = $using:BoundaryStartIP + "-" + $using:BoundaryEndIP
    New-CMBoundary -DisplayName $using:BoundaryName -BoundaryType IPRange -Value $BoundaryValue
    New-CMBoundaryGroup -Name $using:BoundaryGroupName
    Add-CMBoundaryToGroup -BoundaryGroupName $using:BoundaryGroupName -BoundaryName $using:BoundaryName
    New-CMSiteSystemServer -ServerName $using:NewDPServer -SiteCode $using:SiteCode
    Start-Sleep -Seconds 2
    Add-CMDistributionPoint -SiteSystemServerName $using:NewDPServer -SiteCode $using:SiteCode -MinimumFreeSpaceMB $using:MinimumFreeDiskSpace -EnablePxeSupport -AllowRespondIncomingPxeRequest -EnableUnknownComputerSupport -ComputersUsePxePassword $using:PXEPassword -UserDeviceAffinity DoNotUse -PxeServerResponseDelaySeconds 5 -CertificateExpirationTimeUtc $using:CertExpirationDate
    Start-Sleep -Seconds 2
    Foreach($DPGroup in $using:NewDPServer_Groups)
    Add-CMDistributionPointToGroup -DistributionPointGroupName $DPGroup -DistributionPointName $using:NewDPServer
    If you need more information what different valus of variables are i can provide.
    Thank you.
    Kind regards
    Martin Krämer

    Hi,
    Here is the whole script - I'm still testing around this is why it is not really nice at the moment ;-) :
    $DebugPreference = "Continue"
    $Script:Script= $MyInvocation.MyCommand.Definition
    $Script:DebugOut = "Script started: " + "$Script:Script"
    Write-Debug $Script:DebugOut
    $Script:ScriptPath = Split-Path -Path $Script:Script -Parent
    $CertExpirationDate = (Get-Date).AddYears(100)
    #region Setting_Variables
    $NAACred = Get-Credential -Message "provide NetworkAccessAccount credentials:" -UserName "test.loc\NAA_User"
    [string]$RemoteSCCMModule = "D:\ConfigMgr\AdminConsole\bin\ConfigurationManager.psd1"
    [string]$PrimarySiteServer = "Test-Primary"
    [string]$SiteCode = "KN1"
    [string]$NewDPServer = "TEST-DP.test.loc"
    $PXEPassword = ConvertTo-SecureString -AsPlainText "mypass" -Force
    [int]$MinimumFreeDiskSpace = 2000
    [string]$BoundaryName = " "
    [string]$BoundaryStartIP = "192.168.30.1"
    [string]$BoundaryEndIP = "192.168.30.254"
    [string]$BoundaryGroupName = "TEST-DP_Group"
    [array]$NewDPServer_Groups = "04 All Aviable DPs", "01 All PXE DPs"
    #endregion Setting_Variables
    #region REMOTE PrimarySiteServerScript
    <#
    IF ($env:PROCESSOR_ARCHITECTURE -ne "x86")
    Write-Debug "Powershell needs to be in x86 mode. Restarting powershell..."
    $PS32exe = "$env:windir\SysWOW64\WindowsPowerShell\v1.0\powershell.exe"
    if(!(Test-Path $PS32exe))
    Write-Error "x86 Powershell not found!"
    exit
    $powershell = [System.Diagnostics.Process]::GetCurrentProcess()
    $psi = New-Object System.Diagnostics.ProcessStartInfo $powerShell.Path
    $script = $MyInvocation.MyCommand.Path
    $prm = $script
    foreach($a in $args)
    $prm += ' ' + $a
    $psi.Arguments = $prm
    $psi.FileName = $PS32exe
    [System.Diagnostics.Process]::Start($psi) | Out-Null
    exit
    Else
    Write-Debug "Powershell already in x86 mode..."
    if(!(Test-Path $using:RemoteSCCMModule))
    Write-Error "Could not find Remote SCCM Module!"
    Exit
    #>
    <#
    Invoke-Command -ComputerName $PrimarySiteServer -ConfigurationName Microsoft.PowerShell32 -Credential $NAACred -ScriptBlock {
    $DebugPreference = $using:DebugPreference
    Write-Host "------------------NOW Running on REMOTE Primary Site----------------" -BackgroundColor Yellow -ForegroundColor Black
    Write-Debug "Importing SCCM Module..."
    Import-Module $using:RemoteSCCMModule -Force
    $SiteLocation = $using:SiteCode + ":"
    Set-Location $SiteLocation | Out-Null
    if(($using:BoundaryName -ne "") -and ($using:BoundaryName -ne " ") -and ($using:BoundaryName -ne $null) -and ($using:BoundaryName -ne $false))
    $BoundaryValue = $using:BoundaryStartIP + "-" + $using:BoundaryEndIP
    New-CMBoundary -DisplayName $using:BoundaryName -BoundaryType IPRange -Value $BoundaryValue
    New-CMBoundaryGroup -Name $using:BoundaryGroupName
    Add-CMBoundaryToGroup -BoundaryGroupName $using:BoundaryGroupName -BoundaryName $using:BoundaryName
    New-CMSiteSystemServer -ServerName $using:NewDPServer -SiteCode $using:SiteCode
    Start-Sleep -Seconds 2
    Add-CMDistributionPoint -SiteSystemServerName $using:NewDPServer -SiteCode $using:SiteCode -MinimumFreeSpaceMB $using:MinimumFreeDiskSpace -EnablePxeSupport -AllowRespondIncomingPxeRequest -EnableUnknownComputerSupport -ComputersUsePxePassword $using:PXEPassword -UserDeviceAffinity DoNotUse -PxeServerResponseDelaySeconds 5 -CertificateExpirationTimeUtc $using:CertExpirationDate
    Start-Sleep -Seconds 2
    Foreach($DPGroup in $using:NewDPServer_Groups)
    Add-CMDistributionPointToGroup -DistributionPointGroupName $DPGroup -DistributionPointName $using:NewDPServer
    #>
    #endregion REMOTE PrimarySiteServerScript
    #region LOCAL PrimarySiteServerScript
    Write-Host "------------------NOW Running on REMOTE Primary Site----------------" -BackgroundColor Yellow -ForegroundColor Black
    if(!(Test-Path $RemoteSCCMModule))
    Write-Error "Could not find Remote SCCM Module!"
    Exit
    Write-Debug "Importing SCCM Module..."
    Import-Module $RemoteSCCMModule -Force
    $SiteLocation = $SiteCode + ":"
    Set-Location $SiteLocation | Out-Null
    if(($BoundaryName -ne "") -and ($BoundaryName -ne " ") -and ($BoundaryName -ne $null) -and ($BoundaryName -ne $false))
    $BoundaryValue = $BoundaryStartIP + "-" + $BoundaryEndIP
    New-CMBoundary -DisplayName $BoundaryName -BoundaryType IPRange -Value $BoundaryValue
    New-CMBoundaryGroup -Name $BoundaryGroupName
    Add-CMBoundaryToGroup -BoundaryGroupName $BoundaryGroupName -BoundaryName $BoundaryName
    New-CMSiteSystemServer -ServerName $using:NewDPServer -SiteCode $using:SiteCode
    Start-Sleep -Seconds 2
    Add-CMDistributionPoint -SiteSystemServerName $NewDPServer -SiteCode $SiteCode -MinimumFreeSpaceMB $MinimumFreeDiskSpace -EnablePxeSupport -AllowRespondIncomingPxeRequest -EnableUnknownComputerSupport -ComputersUsePxePassword $PXEPassword -UserDeviceAffinity DoNotUse -PxeServerResponseDelaySeconds 5 -CertificateExpirationTimeUtc $CertExpirationDate
    Start-Sleep -Seconds 2
    Foreach($DPGroup in $NewDPServer_Groups)
    Add-CMDistributionPointToGroup -DistributionPointGroupName $DPGroup -DistributionPointName $NewDPServer
    #endregion LOCAL PrimarySiteServerScript
    Thank you for help :-)

  • Invoke-Command Set-Item wsman : Access Denied

    Hi,
    I'm trying to write a script that run another script via an Invoke-Command cmdlet. This script is :
    $usrname = "[email protected]"
    $pwd = "MonPassword"
    $pwd = ConvertTo-SecureString -AsPlainText $pwd -Force
    $cred1 = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $usrname, $pwd
    Invoke-Command -ComputerName "SRVFWL" -FilePath "c:\Scripts\VPNScript.ps1" -Credential $cred1
    So this first script run the next script with the user [email protected] :
    $ID = "UserID"
    $RCMPUSR = "UsrOnVpnCmp"
    $RCMPPWD = "MyPass"
    $RCMPPWD = ConvertTo-SecureString -AsPlainText $RCMPPWD -Force
    $cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $RCMPUSR, $RCMPPWD
    #Connection to RRAS TMG 2010
    $root = New-Object -ComObject "FPC.Root"
    $isaarray = $root.GetContainingArray()
    $sessionmonitor = $isaarray.SessionsMonitors.SessionsMonitorFirewall
    $filter = New-object -ComObject FPC.FPCFilterExpressions
    #Retreive VPN session
    $sessionmonitor.ExecuteQuery($filter,10000)
    #Check session
    foreach($session in $sessionmonitor)
    if($session.ClientIP.StartsWith("10.10."))
    if($session.ClientUserName -eq "MYDOM\\"+$ID)
    Set-Item wsman:\localhost\client\trustedhosts $session.ClientIP -Force
    If((Test-WSMan $session.ClientIP).IsEmpty -eq $false)
    $CMPName = Invoke-Command -ComputerName $session.ClientIP -ScriptBlock {$(Get-WmiObject Win32_Computersystem).name} -credential $cred
    $Version = Invoke-Command -ComputerName $session.ClientIP -ScriptBlock {[Environment]::OSVersion.Version} -credential $cred
    If($Version.Major -eq 6)
    $sessionmonitor.DisconnectSession("MyTMGServer",$session.SessionID)
    $usr = $ID + "@mydom.pri"
    netsh ras set client $usr disconnect
    return $true
    $sessionmonitor.EndQuery()
    This second script run greatly when I run it manually on the local server connected with the svc_scripts user. But I've a Access Denied on the Set-Item cmdlet of the second script when i try to run it with the Invoke-Command.
    I don't understand why this same user are allowed to run the script locally but not allowed on remote computer.
    Can you help me ?
    Thank you.

    Hi Judicael44,
    First You will encounter the second-hop issue when run "invoke-commmand" as the scriptblock in another remote cmdlet, for more detailed information, please refer to this article:
    Enabling Multihop Remoting
    For the error you posted, Let me restate this issue, we have two servers:
    Local server: server1
    remote server: SRVFWL
    So the second script is located on server1, and the user "[email protected]" has admin right on server
    SRVFWL, you got the error "access denied" when ran the script on remote server SRVFWL.
    In this case, please make sure you have ran the cmdlet "Enable-PSRemoting -Force" on server SRVFWL, which will give you the rights to access and modify TrustedHosts setting in WinRm.
    I tested with single cmdlet, and this could work:
    If there is anything else regarding this issue, please feel free to post back.
    If you have any feedback on our support, please click here.
    Best Regards,
    Anna Wang
    TechNet Community Support

  • Invoke-command -computername RemoteServer {start-process c:\install\.bat}

    I am running an invoke command from a PC to run a .bat file on a remote server. However i would like to see the output of the .bat file run in my powershell window on my local PC. Any tips on this?
    I have this at the moment
    invoke-command -computername Server {start-process c:\install\.bat}
    however this just completes without showing  me anything. Can i see the output of the .bat file on my local PC?
    Thanks in advance

    invoke-command -computername Server01 -filepath c:\Scripts\scriptname.ps1
    The script has to be on the local machine or has access to it.
    If this is helpful please mark it so. Also if this solved your problem mark as answer.

  • I've noticed this especially when I youtube or video stream for a while. Switching between tabs takes 3-4 seconds. Definitely a memory leak! Is it a general problem or addon specific?

    I've noticed this especially when I youtube or video stream for a while. Switching between tabs takes 3-4 seconds.
    Definitely a memory leak! Is it a general problem or addon specific?
    Also, when I try to close firefox and restart it, the process doesn'y get killed with the normal Command + Q in Mac.
    I need to use Force Quit instead.

    Try updating Flash. You appear to be running an older version dating from September 2010 which might be the cause of the problem. Download from http://get.adobe.com/flashplayer/
    If the problem persists after updating, try running Firefox in [[Safe Mode]]. If it functions properly in that configuration, then one of your add-ons is the culprit.

  • Invoke-Command - SQL collation change function

    Hi,
    I am creating a script to automatically configure SQL servers in Azure from one of the base Azure SQL VM templates. All of my code works well besides changing the default collation of the instance. The PowerShell code works but the problem is that the
    command only runs the setup.exe command correctly if I have an open RDP session to the server. I'm trying to figure out why it won't run without the RDP session and either work around it or change the code to something that will work consistently. For
    now, I have it open an RDP session but this method won't work in future when I fully automate the scripts.
    Here is my code for the ChangeCollation function:
    FUNCTION ChangeCollation
    param
    [Parameter(Mandatory=$true)]$DeploymentName,
    [Parameter(Mandatory=$true)]$AdminName,
    [Parameter(Mandatory=$true)]$AdminPassword,
    [Parameter(Mandatory=$true)]$Collation
    Write-Host ("Rebuilding instance collation, setting to $Collation ... ") -ForegroundColor Green
    $setup = (Start-Process -FilePath "C:\SQLServer_12.0_Full\Setup.exe" -ArgumentList "/QUIET /ACTION=REBUILDDATABASE /INSTANCENAME=MSSQLSERVER /SQLSYSADMINACCOUNTS=$DeploymentName\$AdminName /SAPWD=$AdminPassword /SQLCOLLATION=$Collation" -NoNewWindow -Wait -PassThru).ExitCode
    If ($setup -eq 0) { Write-Host ("Successfully set collation to $Collation") -ForegroundColor Green}
    If ($setup -ne 0) { Write-Host ("Failed to set collation to $Collation") -ForegroundColor Red}
    I execute it as follows, its in a basic retry loop which tries restarting the services or server if the command fails:
    try
    Invoke-Command -ConnectionUri $uri.ToString() -Credential $credential -ScriptBlock ${function:ChangeCollation} -ArgumentList $DeploymentName, $AdminName, $AdminPassword, $Collation
    $NewCollation = Invoke-Command -ConnectionUri $uri.ToString() -Credential $credential -ScriptBlock {Invoke-SQLCmd "SELECT CONVERT (varchar, SERVERPROPERTY('collation'));"}
    $NewCollation = $NewCollation.Column1
    If ($Collation -ne $NewCollation)
    Throw "Collation not changed exception!"
    $Stoploop = $true
    }Catch{ .......}
    If I have an RDP session open as the local admin which is the same account as I am running the invoke-command with, the setup.exe runs through just fine. Without an RDP session, Invoke waits a minute or two then exits. I can see from the logs on the server
    it hasn't tried to change the collation of the instance.
    I've tried additional switches on the start-process, like -LoadUserProfile or without -nonewwindow but they made no difference. I have also tried changing the collation with the command sqlservr, seems to work sometimes but its inconsistent
    and I don't get the returned result saying that it completed successfully so the code just hangs even after the change.
    Does anyone have any idea why an exe wouldn't work via an invoke without the RDP session? Or alternatively a better way to change the collation of the database which is consistent?

    Hi Federico,
    As Ashwin’s post, before changing server level collation, please check that if the existing SQL Server collation setting of your instance is ‘SQL_Latin1_General_CP1_CI_AS’ with the command below.
    SELECT SERVERPROPERTY(N'Collation')
    Then perform the following steps to change the server level collation and put new collation value.
    1. Record all server-wide configuration values by running the below commands and save the output.
    SELECT * FROM sys.configurations;
    -- OR
    EXEC SP_CONFIGURE
    2. Create and prepare all scripts related to jobs, maintenance plans, logins and their access levels.
    3. Detach all user databases before rebuilding your system databases.
    4. Run your original scripts to rebuild the system databases. Make sure to run this command from the directory where you have placed your SQL Server setup files.
    5. Check the server collation to verify whether this change is successful or not by running the command “SELECT SERVERPROPERTY(N'Collation') ”
    6. Attach all user databases which were detached in Step 3.
    7. Change the collation settings of all user databases.
    ALTER DATABASE DBName collate <NewCollation>
    8. Run all of the which were created in Step 2 to restore jobs, alerts, logins, operators scripts and so on.
    For more details, please review the following blog.
    How to change server level collation for a SQL Server Instance http://www.mssqltips.com/sqlservertip/2901/how-to-change-server-level-collation-for-a-sql-server-instance/
    Thanks,
    Lydia Zhang
    Lydia Zhang
    TechNet Community Support

Maybe you are looking for