besimorhino/Pause-Process

Can't import pause-process.ps1

Opened this issue · 6 comments

Get-Host | Select-Object Version
Version
-------
5.1.18362.752
PS C:\test> Import-Module .\pause-process.ps1                                                                                                                                                                                                 At C:\test\pause-process.ps1:321 char:21
+         <svg class="octicon octicon-sign-out v-align-middle" viewBox= ...
+                     ~~~~~~~
Unexpected token 'octicon' in expression or statement.
At C:\test\pause-process.ps1:395 char:126
+ ... " src="https://avatars0.githubusercontent.com/u/8339596?s=60&amp;v=4" ...
+                                                                 ~
The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quotation marks ("&") to pass it as part of a string.
At C:\test\pause-process.ps1:405 char:116
+ ... -user-status-context pb-1" data-url="/users/status?compact=1&amp;link ...
+                                                                 ~
The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quotation marks ("&") to pass it as part of a string.
At C:\test\pause-process.ps1:405 char:136
+ ...  pb-1" data-url="/users/status?compact=1&amp;link_mentions=0&amp;trun ...
+                                                                 ~
The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quotation marks ("&") to pass it as part of a string.
At C:\test\pause-process.ps1:411 char:19
+   <details class="js-user-status-details details-reset details-overla ...
+                   ~~~~~~~~~~~~~~~~~~~~~~
Unexpected token 'js-user-status-details' in expression or statement.
At C:\test\pause-process.ps1:413 char:58
+       role="menuitem" data-hydro-click="{&quot;event_type&quot;:&quot ...
+                                                          ~
The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quotation marks ("&") to pass it as part of a string.
At C:\test\pause-process.ps1:413 char:65
+ ...   role="menuitem" data-hydro-click="{&quot;event_type&quot;:&quot;use ...
+                                                                 ~
The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quotation marks ("&") to pass it as part of a string.
At C:\test\pause-process.ps1:413 char:89
+ ... ydro-click="{&quot;event_type&quot;:&quot;user_profile.click&quot;,&q ...
+                                                                 ~
The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quotation marks ("&") to pass it as part of a string.
At C:\test\pause-process.ps1:413 char:96
+ ... lick="{&quot;event_type&quot;:&quot;user_profile.click&quot;,&quot;pa ...
+                                                                  ~
Missing expression after unary operator ','.
At C:\test\pause-process.ps1:413 char:96
+ ... ick="{&quot;event_type&quot;:&quot;user_profile.click&quot;,&quot;pay ...
+                                                                 ~
Unexpected token '&' in expression or statement.
Not all parse errors were reported.  Correct the reported errors and try again.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken

I'm unable to reproduce this issue. Can you please provide more info on how you're attempting to do import?

I was talking about this:
https://github.com/besimorhino/Pause-Process

For some reason now works with PowerShell 7.0.3, but some execution policy needs to be changed to prevent this error:

Import-Module: File C:\test\pause-process.ps1 cannot be loaded.
The file C:\test\pause-process.ps1 is not digitally signed.
You cannot run this script on the current system.
For more information about running scripts and setting execution policy, see about_Execution_Policies
at https://go.microsoft.com/fwlink/?LinkID=135170.

You should add to README.md:

# Change execution policy (resets after reboot)
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass

# Actually import
Import-Module .\pause-process.ps1

# Run (no need to import again)
Pause-Process -ID 6592
UnPause-Process -ID 6592

Also add that if you delete the script pause-process.ps1 it stops working. I though it was installed somewhere on the system.

Also I've notices that the import is not persistent between powershell sessions. If I close it and reopen the commands Pause-Process and UnPause-Process are not located. Could this be fixed? Just a wait to permanently install it and persist across reboots.

Also I've notices that the import is not persistent between powershell sessions. If I close it and reopen the commands Pause-Process and UnPause-Process are not located. Could this be fixed? Just a wait to permanently install it and persist across reboots.

This is literally how PowerShell works. If you want to always import the module, you can place the pause-process.ps file in the module folder first (see https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_psmodulepath), and then load it automatically on start with your profile script (see https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_profiles).

I encountered this issue when I attempted to incorrectly invoke-webrequest/wget this file on Windows 10. My mistake was I accidently downloaded this link:

Rather than the raw file output:

Hence why you got raw HTML in the output file and not PowerShell code. 99% sure this can be closed due to user error.