Category Archives: 教學

Enter-PSSession error – chatGPT

Enter-PSSession : Connecting to remote server 192.168.0.888 failed with the following error message : The WinRM client cannot process the request. If the authentication scheme is different from Kerberos, or if
the client computer is not joined to a domain, then HTTPS transport must be used or the destination machine must be added to the TrustedHosts configuration setting. Use winrm.cmd to configure TrustedHosts. Note
that computers in the TrustedHosts list might not be authenticated. You can get more information about that by running the following command: winrm help config. For more information, see the
about_Remote_Troubleshooting Help topic.
At line:3 char:1
+ Enter-PSSession 192.168.0.888 -Credential $cred -ConfigurationName Wi …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (192.168.0.888:String) [Enter-PSSession], PSRemotingTransportException
+ FullyQualifiedErrorId : CreateRemoteRunspaceFailed


ChatGPT said:
ChatGPT
This error usually occurs because PowerShell remoting requires specific configuration, especially when using IP addresses rather than fully qualified domain names, and when the computers aren’t in the same domain. Here are steps to resolve the issue:

TrustedHosts Configuration: Since you’re using an IP address and possibly aren’t in a domain environment, add the target machine’s IP address to your TrustedHosts list. Open PowerShell as an administrator and run:

powershell
Copy code
Set-Item WSMan:\localhost\Client\TrustedHosts -Value “192.168.0.888”
If you need to add multiple IPs, separate them with commas, or use * to allow all hosts.

WinRM Configuration: Make sure WinRM is enabled on both the local and remote machines. Run the following on both systems in an elevated PowerShell session:

powershell
Copy code
winrm quickconfig
Authentication Protocol: If you are not using Kerberos (such as in a workgroup environment), you may need to use a different authentication protocol. For non-Kerberos environments, ensure that Basic Authentication is enabled for the WinRM service. Run this on both systems:

powershell
Copy code
Set-Item -Path WSMan:\localhost\Service\Auth\Basic -Value $true
Use HTTPS (Optional): If you want a more secure connection (especially important for non-domain environments), consider setting up HTTPS for WinRM. This requires setting up an SSL certificate on the target machine.

Restart the WinRM Service: After configuring WinRM, restart it to apply changes:

powershell
Copy code
Restart-Service WinRM
Try the Connection Again: Use Enter-PSSession as before. If you’ve configured TrustedHosts and still encounter issues, specify the authentication type explicitly:

powershell
Copy code
Enter-PSSession -ComputerName 192.168.0.888 -Credential $cred -Authentication Basic
These steps should help resolve the error. Let me know if you encounter any further issues.






You said:
Set-Item WSMan:\localhost\Client\TrustedHosts -Value “192.168.0.888” , this fixed it, but I didnt change anything, why do I need to enter this again ?
ChatGPT said:
ChatGPT
The TrustedHosts setting in PowerShell can sometimes reset or clear under certain circumstances, requiring it to be set again. Here are a few common reasons why this happens:

System or Service Restart: If the WinRM service (Windows Remote Management) is restarted, it may sometimes reset TrustedHosts, especially if configured via Group Policy or in specific environments.

Group Policy: In some cases, Group Policy settings might override local configurations. For example, if your system is in a workgroup or receives Group Policy updates from a management server, these updates could reset or modify the TrustedHosts list.

Network Profile Changes: Changing network profiles (e.g., from private to public) or network configurations can also trigger updates to settings related to security, which might affect TrustedHosts.

Windows Updates or Patches: Occasionally, Windows updates that include security fixes or changes to WinRM behavior could reset settings to defaults for security reasons.

If this setting is essential for your workflows, you could create a startup script to ensure TrustedHosts is set consistently. This way, if the configuration resets, it’ll automatically reapply when you start your system.

Running .BAT or .CMD files hidden (invisible mode) Using NirCmd

NirCmd is a multipurpose command-line automation utility from the third-party vendor Nirsoft. We’ve covered NirCmd many times in the past on our site.

We can use NirCmd to run a program, script or batch file in hidden mode.

Download NirCmd and extract the file to your Windows directory.

From the Run dialog or Command Prompt, use the following syntax to launch a batch file or program in hidden mode:

C:\Windows\nircmd.exe exec hide C:\Users\PC\Downloads\PC move\move.bat

Using Google Home / assisntant voice command to turn on my PC with Wake-on-LAN via samung galaxy s10

Using Google Home – google assisntant voice command to turn on my PC with Wake-on-LAN , require a samsung galaxy android device with with Bixby Routine built in , which should be galaxy s10 or above. eg: s20, note 10, note 20

The only extra app required is “Wake On Lan” by Mike Webb
No website login or coding is required

Powershell reminder

Enter-PSSession -ComputerName 192.168.0.131 -Credential XX
Get-Counter ‘\Processor(_Total)\% Processor Time’

Save into a PS1 file

Create a short cut
powershell.exe -noexit -ExecutionPolicy Bypass -File “C:\Users\STAFF\Desktop\enter.PS1”

Quickly change windows text scaling DPI between 125% 150% and 175% using bat files

toggle between 125% DPI and 175% DPI

@ECHO OFF

explorer ms-settings:display
timeout /T 1

:VBSDynamicBuild
SET TempVBSFile=%tmp%\~tmpSendKeysTemp.vbs
IF EXIST “%TempVBSFile%” DEL /F /Q “%TempVBSFile%”
ECHO Set WshShell = WScript.CreateObject(“WScript.Shell”) >>”%TempVBSFile%”
ECHO Wscript.Sleep 1600 >>”%TempVBSFile%”
ECHO WshShell.SendKeys “{TAB}{TAB}{UP}{UP}” >>”%TempVBSFile%”
ECHO Wscript.Sleep 500 >>”%TempVBSFile%”
ECHO WshShell.SendKeys “%%{F4}” >>”%TempVBSFile%”

CSCRIPT //nologo “%TempVBSFile%”
EXIT

—– > save to a BAT file for decrease from 150 to 125%

@ECHO OFF

explorer ms-settings:display
timeout /T 1

:VBSDynamicBuild
SET TempVBSFile=%tmp%\~tmpSendKeysTemp.vbs
IF EXIST “%TempVBSFile%” DEL /F /Q “%TempVBSFile%”
ECHO Set WshShell = WScript.CreateObject(“WScript.Shell”) >>”%TempVBSFile%”
ECHO Wscript.Sleep 1600 >>”%TempVBSFile%”
ECHO WshShell.SendKeys “{TAB}{TAB}{DOWN}{DOWN}{DOWN}” >>”%TempVBSFile%”
ECHO Wscript.Sleep 500 >>”%TempVBSFile%”
ECHO WshShell.SendKeys “%%{F4}” >>”%TempVBSFile%”

CSCRIPT //nologo “%TempVBSFile%”
EXIT

—– > save to a BAT file for increase from 150 to 175%

explorer ms-settings:display
timeout /T 1

:VBSDynamicBuild
SET TempVBSFile=%tmp%\~tmpSendKeysTemp.vbs
IF EXIST “%TempVBSFile%” DEL /F /Q “%TempVBSFile%”
ECHO Set WshShell = WScript.CreateObject(“WScript.Shell”) >>”%TempVBSFile%”
ECHO Wscript.Sleep 5 >>”%TempVBSFile%”
ECHO WshShell.SendKeys “{TAB}{TAB}{UP}{UP}{UP}{UP}{DOWN}{DOWN}” >>”%TempVBSFile%”
ECHO Wscript.Sleep 5 >>”%TempVBSFile%”
ECHO WshShell.SendKeys “%%{F4}” >>”%TempVBSFile%”

CSCRIPT //nologo “%TempVBSFile%”
EXIT

—– > save to a BAT file for reset to 150%

actually need to adjust the ECHO WshShell.SendKeys “{TAB}{TAB}{UP}{UP}”
depends on different computer’s display setting
set to the correct sequence , depends on your graphic card

Must reset back to 150% before using the 125 / 175 bat files