Comments (12)
I could help with server tests if you want.
from invoke-commandas.
I've installed Powershell 7.0.0-rc.1 on both my client (source) and my server (destination).
Every time i execute Invoke-CommandAs, it returns PSVersion 5.1... can't get it to run on 7 in my remote session.. am i missing something?
Code i use to test:
Import-Module .\Invoke-CommandAs -Force
If (!$Credential) { $Credential = Get-Credential '.\Administrator' }
If (!$PSSession) { $PSSession = New-PSSession -ComputerName '192.168.86.80' -Credential $Credential }
$ScriptBlock = {
Write-Warning "Computer : $($Env:ComputerName)"
Write-Warning "PSVersion : $($PSVersionTable.PSVersion.ToString())"
[System.Security.Principal.Windowsidentity]::GetCurrent()
}
Invoke-CommandAs -Session $PSSession -ScriptBlock $ScriptBlock -ASSystem
Result:
RunspaceId : ee68d0d2-4a5d-4f4d-afe8-a39bea22cbba
AuthenticationType : NTLM
ImpersonationLevel : None
IsAuthenticated : True
IsGuest : False
IsSystem : True
IsAnonymous : False
Name : NT AUTHORITY\SYSTEM
Owner : S-1-5-18
User : S-1-5-18
Groups : {S-1-1-0, S-1-5-32-545, S-1-5-6, S-1-2-1…}
Token : 2116
AccessToken : Microsoft.Win32.SafeHandles.SafeAccessTokenHandle
UserClaims : {http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name: NT AUTHORITY\SYSTEM, http://schemas.microsoft.com/ws/2008/06/identity/claims/primarysid: S-1-5-18,
http://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid: S-1-1-0, http://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid: S-1-5-32-545…}
DeviceClaims : {}
Claims : {http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name: NT AUTHORITY\SYSTEM, http://schemas.microsoft.com/ws/2008/06/identity/claims/primarysid: S-1-5-18,
http://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid: S-1-1-0, http://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid: S-1-5-32-545…}
Actor :
BootstrapContext :
Label :
NameClaimType : http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name
RoleClaimType : http://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid
WARNING: Computer : MK-TESTSERVER
WARNING: PSVersion : 5.1.14393.3383
What am i doing wrong?
from invoke-commandas.
From within Windows PowerShell on your target machine (server), run Get-PSSessionConfiguration and you will see the available session configurations.
Currently, the microsoft.powershell endpoint is the default, even when remoting from PowerShell Core or PowerShell 7.
I believe Steve Lee on the PowerShell mentioned on Twitter recently that they plan to change this behaviour in PowerShell 7.1, so that the latest PowerShell 7.x session configuration will be the default.
Until then, you can simply specify -ConfigurationName when using Invoke-Command/New-PSSession:
Invoke-Command -ComputerName . {$PSVersionTable} -ConfigurationName PowerShell.7.0.0-rc.2
This will of course require that Enable-PSRemoting has been run in PowerShell 7.
from invoke-commandas.
Had been a while ago and i'd like to ask if there is something in the pipe regarding powershell 7.2.
from invoke-commandas.
I have t had an opportunity or requirement to do any work on this for my work. If someone cares to give it a try and submit a PR, I’d gladly test and merge this in.
from invoke-commandas.
However, in PowerShell 7 it seems like the PSScheduledJobs [sic] module is back, but there is a different error:
I think this was a false alarm. As of Powershell 7.4 that module is not available and shows a similar error as mentioned under 6.x. For additional explanation it suggests running Import-Module which says this:
Module 'PSScheduledJob' is blocked from loading using Windows PowerShell compatibility feature by a 'WindowsPowerShellCompatibilityModuleDenyList' setting in PowerShell configuration file.
See also PowerShell/PowerShell#12743 (comment)
So the underlying issue for PS 6 and 7 support is that the PSScheduledJob module is no longer available.
Edit: Corrected module name PSScheduledJob singular, not PSScheduledJobs
from invoke-commandas.
Has anyone worked on this? Is there a fix?
from invoke-commandas.
Within the last days I'm looking for a solution on that issue.
Due to the fact, that scheduled jobs are not supported in PSCore, I'll trying the following workaround:
- Issue the scriptblock as scheduled task
- store the result in a temp file (serialized to be compatible with 5.1)
- return the result of that file
On my home Win10 it already looks promissing. But I have to look for the opportunity to test it with Windows server releases local and via remote sessions.
Additionally, I would like to upgrade tests to Pesterv5 syntax.
from invoke-commandas.
Thanks for your offer. I managed to get a local container running for first server tests. If it's ready, I'll come back to it.
from invoke-commandas.
@dcmacdonald : I've prepared a first version of my idea of supporting PS7 (https://github.com/danubie/Invoke-CommandAs/tree/PS7-support).
What it does: To replace the missing 'Register-ScheduledJob' my solution
- creates a temp. file containing the script parameters
- creates a temporay file containing an intermediate scriptblock
- then schedules a task to execute the intermediate script
- this executes the custom scriptblock, captures pipeline output and stores results to be returned
Open issue:
scriptblock haveing $using. I did not use this kind of scriptblock feature with Invoke-CommandAs, Maybe @mkellerman has an example for me.
I would greatly appreciate tests by you. Local tests using the powershell core container and a test system at our company did quite well.
@mkellerman: Is this idea for supporting PS7 ok for you?
Thanks in advance,
Wolfgang
from invoke-commandas.
@danubie, nice work! I would recommend not using files writen to disk for the scriptblock and parameters. I'll need some time to evaluate (which i'm unfortunatly limited on).
from invoke-commandas.
Related Issues (20)
- Access is denied. on localhost HOT 6
- Unable to invoke command as gMSA - v3.1.2 HOT 11
- Access Denied with -RunElevated HOT 3
- AsUser Doesn't Impersonate user HOT 10
- Removing entries from the Task Scheduler log HOT 3
- $Using: variable preface not respected HOT 6
- Module on Powershell Core HOT 2
- Erro running RunElevated parameter HOT 4
- PowerShell Core Compatiblility HOT 2
- Not working when using variables in script block HOT 3
- Can't figure out the right amount of permission HOT 2
- Unable to submit credential objects as arguments HOT 6
- AsSystem doesn't seem to execute while device is on battery power HOT 4
- Would it be possible to run -AsLocalService HOT 1
- Invoke-CommandAs -AsSystem broke on 2012 R2 ENG
- Add support for Network Service HOT 1
- Add tagging to Azure pipeline for releases HOT 2
- parsing error when using -FilePath HOT 3
- Calling via NT Authority\SYSTEM - requires elevation? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from invoke-commandas.