Powershell Exception: Not enough quota is available to process this command - powershell

I am running a simple cmdlet with Powershell 5.1, winver 1803.
I am running:
Rename-Computer -ComputerName $pc -NewName $newName -DomainCredential $cred -Restart
This command is part of a script. Everything in the script works - and this line used to work, but for some reason it stopped.
The exception is:
Fail to rename computer '$pc' to '$newName' due to the following
exception: Not enough quota is available to process this command.
There are no memory or page-file size issues. There are no other applications even running. Page file size is in excess of 8GB.
WinRM is running, stack 3.0.
Why on earth is this command producing this error? How might I troubleshoot it?
UPDATE
This is what I am seeing...
Rename-Computer : Fail to rename computer 'W4000100' to 'W1401-TR100'
due to the following exception: Not enough quota is available to
process this command. At line:2 char:9
+ Rename-Computer -ComputerName $pc -NewName $newName -DomainCr ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (W4000100:String) [Rename-Computer], InvalidOperationException
+ FullyQualifiedErrorId : FailToRenameComputer,Microsoft.PowerShell.Commands.RenameComputerCommand
Rename-Computer : Fail to rename computer 'W4000100' to 'W1401-TR100'
due to the following exception: Not enough quota is available to
process this command. At line:2 char:9
+ Rename-Computer -ComputerName $pc -NewName $newName -DomainCr ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (W4000100:String) [Rename-Computer], InvalidOperationException
+ FullyQualifiedErrorId : FailToRenameComputer,Microsoft.PowerShell.Commands.RenameComputerCommand
Again, this same message pops up if you try to rename a computer locally via the GUI, and also happens if I remove the hyphen from the name, etc.

After researching, I believe this solution may solve your issue from the following article by Phil Coutard:
http://blog.coultard.com/2012/01/fix-windows-error-0x80070718-not-enough.html
This might be set on the user level. Try going to Control Panel, Sync Center, Offline Files, Manage Offline Files (left hand side), Disk Usage tab, Change Limits. It could be that your Disk Usage has a limit. Try that first and see if that fixes it.
UPDATE:
If that doesn't work, since the error is so generic, I would recommend using Microsoft's Automatic diagnostic/repair tool: https://support.microsoft.com/en-us/help/17590/automatically-diagnose-and-repair-windows-file-and-folder-problems

The answer after troubleshooting with MS is that the image used for these systems was domain-joined at the time of capture. This results in each machine having the same AccountDomainSID, which apparently can cause many issues - however, this is the only issue we have identified as a result.
MS have pretty much stopped researching with me and say this is the cause and that the only fix is to remove from domain and rejoin.

Related

PowerShell Import-GPO: Operation not valid

Afternoon everyone. I'm running into an issue I'm not sure how to handle. I'm working on a script for work to deploy a Domain Controller using PSremoting. It all works well in fine until I get to where I'm importing some GPOs from backups.
*All the commands are run under invoke-command
I run the command Import-GPO -BackUpName $GPO -TargetName $GPO -Path $GPOPath -MigrationTable $MigTable -CreateIfNeeded
When I run this, I get an error on the host:
Operation is not valid due to the current state of the object.
+ CategoryInfo : NotSpecified: (:) [Import-GPO], InvalidOperationException
+ FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.GroupPolicy.Commands.ImportGpoCommand
+ PSComputerName : v204-DC1
I can't seem to find anything that says what this means. When I check for the GPOs on the DC, they all show up and seem to be linked properly. I am curious what this error is, or if I should just append -ErrorAction SilentlyContinue to the end of my code.
Ended up being an issue with my migration table. I rolled back to an earlier one and ended up being good to go

PowerShell How to suppress error messages

Whenever I run Update-Help, I get tons of errors. I've given up trying to resolve these, it's just how PowerShell works, some help file definitions always fail to update (but if anyone knows how to resolve these I would be interested to try).
So, I want to suppress the errors from my script that updates this stuff every month.
I've tried Update-Help -EA silent and Update-Help -EA silent | Out-Null but in both cases, the error messages are still sprayed on the screen in red.
Does anyone know hot to suppress these?
Update-Help : Failed to update Help for the module(s) 'AppvClient, ConfigDefender, Defender, HgsClient, HgsDiagnostics,
HostNetworkingService, Microsoft.PowerShell.ODataUtils, Microsoft.PowerShell.Operation.Validation, Sudo, UEV, Whea,
WindowsDeveloperLicense' with UI culture(s) {en-GB} : Unable to connect to Help content. The server on which Help content is stored
might not be available. Verify that the server is available, or wait until the server is back online, and then try the command again.
At C:\Users\Boss\AppData\Local\Temp\BeginSystemConfig.ps1:571 char:9
+ Update-Help
+ ~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Update-Help], Exception
+ FullyQualifiedErrorId : UnableToConnect,Microsoft.PowerShell.Commands.UpdateHelpCommand
Update-Help : Failed to update Help for the module(s) 'WindowsUpdateProvider' with UI culture(s) {en-GB} : Unable to retrieve the
HelpInfo XML file for UI culture en-GB. Make sure the HelpInfoUri property in the module manifest is valid or check your network
connection and then try the command again.
At C:\Users\Boss\AppData\Local\Temp\BeginSystemConfig.ps1:571 char:9
+ Update-Help
+ ~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (:) [Update-Help], Exception
+ FullyQualifiedErrorId : UnableToRetrieveHelpInfoXml,Microsoft.PowerShell.Commands.UpdateHelpCommand
This will help you:
Update-Help -ErrorAction SilentlyContinue
Or
Try {
Update-Help -ErrorAction Stop
# Use this method only if you want to halt script on errors
}
Catch {
# Place action on error here
}
Do not forget that WarningAction exists.
I'm not sure it applies to you, but I was trying to suppress the 'SystemRestorePointCreationFrequency' output of Checkpoint-Computer and it is a Warning--not an Error. The following will suppress that warning:
Checkpoint-Computer -Description "my description" -RestorePointType "MODIFY_SETTINGS" -WarningAction SilentlyContinue

BizTalk 2016 wmi query failing

In our Powershell deployment scripts we terminate inflight instances identified by the following query:
get-wmiobject -namespace Root\MicrosoftBizTalkServer -query "SELECT * FROM MSBTS_ServiceInstance WHERE (ServiceClass = 1 OR ServiceClass = 64) AND AssemblyName LIKE 'Our.AssemblyName'"
For some reason this has stopped working on a Windows 2016 server, failing with this message:
get-wmiobject : An internal failure occurred for unknown reasons.
At line:1 char:1
+ get-wmiobject -namespace Root\MicrosoftBizTalkServer -query "SELECT * ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Get-WmiObject], COMException
+ FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
Some searching has pointed to recent OS security patches. We uninstalled the KB mentioned from all nodes.
The above query runs without failure on 2 nodes in one environment and 1 node in another. This one box still gives the above error. Not sure what caused the original problem but maybe the uninstall did not clean up properly.
Any ideas where to start looking to fix the problem? I was thinking maybe installing the patch again and uninstalling it to make sure it cleans up properly. It takes about 4 hours for the VM to boot after the uninstall so testing such theories take a long time.
Turns out we have auto patching that kept re-applying the patch. What added to the confusion was the patch number being different for each OS and then there is the 4 hour thing that made it really difficult to poke the issue.
On 2016 it is KB4345418 that is causing the problem.

Win32Shutdown Generic Failure

I am putting together a script which will log off VDI sessions which have been in a disconnected state for over 10 hours. I have managed to get everything together except for the last hurdle - actually forcing a logoff.
ForEach ($Desktop in $VDIlist)
{
$win32OS = Get-wmiobject win32_operatingsystem -ComputerName $desktop.'DNS Name' -EnableAllPrivileges
write-host "Shutting down host $Desktop."DNS Name""
$win32OS.Win32Shutdown(4)
}
This results in the error below.
Exception calling "Win32Shutdown" : "Generic failure "
At line:1 char:1
+ $win32OS.win32shutdown(4)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : WMIMethodException
This does not appear to happen when no argument is used
($win32os.win32shutdown()), but this also does not force the log off like I require.
As far as I have read the -EnableAllPrivileges parameter should allow for the remote log off and it does work if I have a live PCoIP session to the VDI I am attempting to shutdown but not when in a disconnected state.
Could anyone point me in the right direction?
Still not entirely sure why the first script is giving an error but I have instead switched to using VMWare View's built in PowerCLI snapin to produce the same result - just faster and more efficiently.
get-remotesession -state "Disconnected" | Where-Object {($_.duration -match 'Day' -or $_.duration -match '\d\d hours')} | Send-SessionLogoff
This will query the Horizon view server for any sessions with the "Disconnected state", it will then filter out any objects that have had a lifetime of less than 10 hours and log off anything that is left.
This requires VMware View PowerCLI PSSnippets to be loaded and connected to your view connection broken.

Random errors while doing Enter-PSSession in powershell

I have setup lots of Powershell scripts on my WIndows 2008 R2 server. The scripts do lots of processing (data crunching, executing SQLCMD.exe, bcp.exe etc). All of these scripts work without issues.
I am trying to call and execute the scripts from a remote laptop (within the same network) using the following command:
Enter-PSSession -ComputerName sun -ConfigurationName myprofile
The "myprofile" currently has just one function that will change directory to c:
This allows me to execute the scripts from my local laptop, however, they "run" on the server. That is my understanding.
However, I have not seen any scripts execute fully. At random intervals, the scripts fail with the below error messages... Once again, I have never seen these errors when I am trying to run the scripts on the server itself.
Any inputs on how to "fix" these errors? Any settings that I need to do on the "client" in terms of memory allocation?
a.
Processing data for a remote command failed with the following error message: Not enough storage is available to complete this operation. For more information, see the about_Remote_Troubleshooting Help topic.
b.
Get-Content : Exception of type 'System.OutOfMemoryException' was thrown.
At E:\automation\mssql-upload.ps1:144 char:14
+ (get-content <<<< $PipeFile -ReadCount 1000) | set-content $FinalFile
+ CategoryInfo : InvalidOperation: (:) [Get-Content], OutOfMemoryException
+ FullyQualifiedErrorId : ProviderContentReadError,Microsoft.PowerShell.Commands.GetContentCommand
c.
[Microsoft] [ODBC Driver Manager] Driver's SQLAllocHandle on SQL_HANDLE_ENV
d.
Processing data for a remote command failed with the following error message: The WSMan provider host process did not return a proper response. A provider in the host process may have behaved improperly. For more information, see the about_Remote_Troubleshooting Help topic.
It is likely your remote session is bumping up against the WS-Man quota MaxMemoryPerShellMB. You can see the current value by executing this command on the remote machine:
Get-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB
You can set a new value like so:
Set-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB 512 -Force
This sets the value at 512MB. Set it to a value that works for your application.