PowerShell fails when trying to read certificate store with "The specified network resource or device is no longer available" - powershell

I was trying to find a specific certificate on my machine, and I ran into an odd issue. I was seeing The specified network resource or device is no longer available errors when calling:
Get-ChildItem -Path "XXXXX" -Recurse
Where "XXXX" was the thumbprint of the certificate I was looking for.
To try to narrow down the issue, I started by removing the thumbprint of my command (i.e. calling Get-ChildItem -Recurse), and found that the script failed when trying to read from the UserDS certificate store (see abbreviated screenshot of output, below):
I then tried to cd into the UserDS certificate store to see if it would even let me, and to see if I could see anything in that location. Upon trying to call ls I received the same error (see below):
I can't figure out what's causing this issue or how to fix it. It's blocking me on the local installation of a client's solution, so any help or ideas are very much appreciated. Thanks!

The UserDS store (or Active Directory User Object in the certmgr.msc) displays active directory stored certificates of the user (see here, here, here and here).
The error 0x80070037 (the specified network resource or device is no longer available) message occurs when a local device (like an usb stick is unavailable) or a network connection is interrupted while accessing a resource.
The store has a key in the windows registry (Computer\HKEY_CURRENT_USER\Software\Microsoft\SystemCertificates\UserDS) and saves information on certificates which are read from active director.
I see two options:
The information in the registry is corrupt
you have issues accessing the active directory
If you want to handle the error when calling Get-ChildItem look at this SO post

Related

WinSCP PUT command errors out with "Unknown switch 'rawtransfersettings'"

We have a job which is located in Windows server and this job is responsible for sending files to a Linux box through WinSCP utility.
We observed that file transfer process failing due to the connection error on an average every alternate day.
We are getting below error message in logs:
Upload of file 'xxx_20190103031754.csv' was successful, but error occurred while setting the permissions and/or timestamp.
If the problem persists, turn off setting permissions or preserving timestamp.
Alternatively you can turn on 'Ignore permission errors' option.
General failure (server should provide error description).
In order to fix the issue I googled to set -rawtransfersettings for put command
open sftp://xxx#xxx.example.com/ -hostkey="ssh-rsa 1024 xx:xx:xx:xx:xx:xx" -timeout=60 -rawsettings SendBuf=0 SshSimple=1
put -rawtransfersettings IgnorePermErrors=0 PreserveTimeDirs=0 "E:\Final\XXX_ASSIGNMENT_20190416200819.csv" "/<Linux Box Folder Name>/"
But I am getting below error
Authenticating with pre-entered password.
Authenticated.
Starting the session...
Session started.
Active session: [1] xxx#xxx.com
Unknown switch 'rawtransfersettings'.
The -rawtransfersettings switch is supported by the latest WinSCP 5.15 only. You are probably using an older version of WinSCP.
Also, if your goal was to to enable "Ignore permission errors", you need IgnorePermErrors=1 (0 is the default value).
Side notes: PreserveTimeDirs is not related to your problem and is 0 by default anyway. So you can remove that. And the double slash is suspicious, you should probably use one only.
This should do:
put -rawtransfersettings IgnorePermErrors=1 "E:\Final\XXX_ASSIGNMENT_20190416200819.csv" "/"
But if your server actually does not support preserving timestamps, then you should rather use -nopreversetime switch. See the documentation for the error message:
When using scripting, add -nopreservetime and -nopermissions switches to put command.

Using WGET to retrieve information from PLC - Error 400 Bad Request

I'm attempting to use the wget program to retrieve and save a list of data from my Siemens S7-1200 PLC. Using a batch file I had written I was able drill down the folder path to my wget.exe file. Upon running the wget executable I get the error message seen in the attached screenshot, labeled "Command Prompt Screenshot".
The command prompt shows me that I've "connected" and I know the username and password are correct because I can log into the PLC using my web browser. It's for those reasons I'm stumped on what the problem is.
Has anyone seen this before or can anyone point me in the right direction?
Thanks for the response Ken. I was actually able to get it working with the assistance of the Siemens technical support. Apparently my computer didn't like the way I was trying to pass it the username and password login credentials. Through Siemens TIA Portal software I was able remove the login restrictions, allowing all users access to reading data off the PLC and it works now. I've attached a copy of the exact batch file I used. Also, to make sure I'm adding as much detail as possible, I have the batch file and the wget.exe file saved to a folder on my c:\ drive. Functional wget batch file

Powershell: accessing remote registry via WMI

I have a script that simply connects to the registry of a remote computer via WMI and Powershell:
$Server = server1
$HKLM = [UInt32] "0x80000002"
$WMI_Reg = [WMIClass] "\\server1\root\default:StdRegProv"
For the majority of our 300 servers this is fine and I can make subsequent queries on the registry. However, for a select few, I get this error:
Cannot convert value "\server1\root\default:stdregprov" to type
"System.Management.ManagementClass". Error: "not found"
These are all 2008 R2 servers. Originally, there were issues with invalid WMI providers and I had to recompile cimWin32.mof prior to this error.
Any ideas on what I can do next?
Thanks
These errors are usually caused by missing WMI classes. The solution for this kind of error usually involves couple of steps.
The solutions could be found under this link: https://blogs.technet.microsoft.com/askperf/2014/08/11/wmi-missing-or-failing-wmi-providers-or-invalid-wmi-class/
Important: as per Microsoft, please don't rebuild mof files as the first step:
"Rebuilding the repository or recompiling all of the .mof files as a first action when other steps should be taken first can cause damage to the system and/or to installed applications."
Cannot convert value "\server1\root\default:stdregprov" to type "System.Management.ManagementClass". Error: "not found"
This error is because it did not find the key that you are looking for. That's a basic case when key does not exist. Can you check if registry key exists?
As per the information provide, there is no issue with WMI here.
You can always use try and catch block to throw exception and move forward.

Social Engineering Toolkit Errors

I'm trying to use the Infectious Media Generator to practice some pen-testing with a USB. As I go through the process, after I put the port number I get this:
set:payloads> Port to connect back on [443]:443
[-] Generating fileformat exploit...
[*] Payload creation complete.
[*] All payloads get sent to the /root/.set/template.pdf directory
[!] Something went wrong, printing the error: name 'src' is not defined
I saw something that said to update, however when I run ./seupdate it erases everything about SET and says it needs a directory to specify where it's pulling information from. I initially tried routing to github but that didn't work.
There is also the issue that the user manual specifies using the ./set-update command however I can't find that executable anywhere in my directory.
I also tried running the command on SET's website to install SET but that didn't work either which is why I downloaded the .zip and extracted it. Anyone run into these errors?

'DefaultAppPool' is being automatically disabled due to a series of failures

Having a tough time with this issue. Not sure how but my ApplicationPoolIdentity is broken.
Currently I'm running IIS 8 on Windows 8 with Visual Studio 2012. When trying to debug an application from Visual Studio, or just navigating to the site in a browser I get the following error logged and a 503 error.
Application pool 'DefaultAppPool' is being automatically disabled due to a series of failures in the process(es) serving that application pool.
If I check out the Application error logs, I find the following error from the User Profile Service.
Windows cannot log you on because your profile cannot be loaded. Check that you are connected to the network, and that your network is functioning correctly.
DETAIL - The system cannot find the path specified.
Upon looking into the details I find that the User Profile Service is trying to load up a profile with the Id
S-1-5-82-3006700770-424185619-1745488364-794895919-4004696415
Now I opened up the registry to try and find the profile with that UserId. However there's nothing in the Profile list that helps.
So digging around a little more I've found that this issue can be resolved by either
A) Set the Load User Profile of the Application Pool to false.
B) Use a different account for the application pool.
C) Fix the account.
Seeing how this is the built in account, I'd prefer to fix the issue rather than fix the sympton.
What I have tried
aspnet_regiis -i
Removing IIS from windows and reinstalling.
Attempted to follow the guide here but I don't know the account password :P
My hunch
Somehow the ApplicationPoolIdentity got messed up. Is there any physical folders for the built-in accounts? I know that the Network and Local service profiles physical directories exist at C:\Windows\ServiceProfiles\. It is possible to recreate the ApplicationPoolIdentity profile? Or am I way off on what the real issue is?
C) Here is what i did to fix the account
Go in regedit at key
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
There is a setting called "Default". You have to make sure that the data value point to an existing directory on the drive.
By default it contains "%SystemDrive%\Users\Default". In my company the default is changed to a custom profile. Somehow, someone deleted that user profile. So when the defaultAppPool user tryed to create an accound for himself, it was unable to do so because windows cannot provide him with a default user profile.
You can also diagnose this error when looking at the Event Viewer under the Application folder. You will get a message of that type:
Windows cannot find the local profile and is logging you on with a
temporary profile. changes you make to this profile will be lost when
you log off.