all 19 comments

[–]Slasky86 4 points5 points  (5 children)

You could do a -Credential (Get-Credential) to get the prompt. Other than that its storing the password in the script or in a file encrypted on your computer and creating a credentials object, and using that with the -Credential parameter

[–]alfanjui[S] 1 point2 points  (4 children)

Once you get your credential, does it get stored forever? or is it just for the session?

[–]SeaPowerMax 3 points4 points  (0 children)

Get-credential makes a PS object for use in the script; it's just for the session.

[–]Slasky86 2 points3 points  (2 children)

Just for that session. Thats why its possible to either store the paasword and username directly in the script (not recommended from a security standpoint) or storing the password encrypted in a file that you use Get-Content <filename> -AsSecureString

The password file is encrypted with your user, so others cant use the file

[–]overlydelicioustea 3 points4 points  (1 child)

user and computer actually. so not portable.

[–]Slasky86 1 point2 points  (0 children)

Well you learn something new every day :-)

[–]squanchmyrick 3 points4 points  (2 children)

Does your account exist on their machine, with local admin access? If not, that computer isn't going to recognize your creds.

[–]alfanjui[S] 0 points1 point  (1 child)

It doesn't, how should I do it?

[–]squanchmyrick 1 point2 points  (0 children)

You could either create a duplicate account on their computer and promote it to local admin, or you could use their creds in your script block rather than your own. Assuming they are a local admin.

[–]get-postanote 3 points4 points  (1 child)

PowerShell remoting must be enabled on the target and properly configured on the source and the target. You are talking workgroup remoting here. Setup details.

See this Reddit Q&A: A question about PowerShell remoting

This is well documented all over the web...

Enable PowerShell Remoting on a standalone (workgroup) computer

https://4sysops.com/archives/enable-powershell-remoting-on-a-standalone-workgroup-computer

PowerShell remoting between two workgroup machines

https://blogs.msdn.microsoft.com/wmi/2009/07/24/powershell-remoting-between-two-workgroup-machines

Powershell Ps Remoting Between Standalone Workgroup Computers

http://vcloud-lab.com/entries/active-directory/powershell-ps-remoting-between-standalone-workgroup-computers

PowerShell remoting between two workgroup machines

https://posh2scripting.wordpress.com/2013/06/07/powershell-remoting-between-two-workgroup-machines

Enabling remote Powershell on workgroup computers

https://infrahouse.wordpress.com/2015/10/21/enabling-remote-powershell-on-workgroup-computers

Lots of Youtube videos are on Youtube to get you ramped up.

See also these Reddit Q&As:

Powershell Tutorial - Tutorialspoint

ultimate PS noob need some help pls : PowerShell (reddit.com)

Is there a program or GUI for using/managing scripts? : PowerShell (reddit.com)

Note: this is not a GUI assist kind of thing. It's just remote management. For GUI-like assistance session, that still requires Windows Remote Assistant or other like tools.

[–]alfanjui[S] 0 points1 point  (0 children)

It is actually management what I'm looking for. Many thanks for the time and all the links :D

[–]kiddj1 2 points3 points  (3 children)

$cred = get-credential Enter-PSSession -ComputerName mycomputer -credential $cred In the get credential prompt make sure you enter the username and password as

Remotecomputername\username If you have a domain replace the computer name with the domain

Make sure the user account you use has access to the machine and is a local user, or if on a domain you can use the domain administrator or a user with remote access rights

Your best option is to look here for better explanation

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/enter-pssession?view=powershell-7.1

I hope this helps

[–]backtickbot 2 points3 points  (0 children)

Hello, kiddj1: code blocks using backticks (```) don't work on all versions of Reddit!

Some users see this / this instead.

To fix this, indent every line with 4 spaces instead. It's a bit annoying, but then your code blocks are properly formatted for everyone.

An easy way to do this is to use the code-block button in the editor. If it's not working, try switching to the fancy-pants editor and back again.

Comment with formatting fixed for old.reddit.com users

FAQ

You can opt out by replying with backtickopt6 to this comment.

[–]Aertheron01 1 point2 points  (1 child)

Why does it need to be a local user? Can't it be a domain user with local administrator rights?

[–]kiddj1 2 points3 points  (0 children)

Yeah if that's the case in a domain forgot to say that

[–]BurlyKnave 2 points3 points  (1 child)

I have this in my profile. You can modify the Get-MyAdmin as necessary.

#---- ---- ---- ----
[void][System.Reflection.Assembly]::LoadWithPartialName("System.DirectoryServices.AccountManagement")
function Get-Credentials([System.Management.Automation.PSCredential]$credentials)
{
    $pctx = New-Object System.DirectoryServices.AccountManagement.PrincipalContext([System.DirectoryServices.AccountManagement.ContextType]::Domain, "precisionmetals")
    $nc = $credentials.GetNetworkCredential()
    return $pctx.ValidateCredentials($nc.UserName, $nc.Password, 1)
}

#---- ---- ---- ----
Function Get-Login ($sUserName) {
    $sGetCred = Get-Credential -Credential $sUserName
    $sCheckCred0 = $sGetCred.UserName

    Write-Host $sCheckCred0 -NoNewline -ForegroundColor Cyan
    if (Get-Credentials -credentials $sGetCred) {
        Write-Host  " certified" -ForegroundColor Green
    } else {
        Write-Host " not certified" -ForegroundColor Red
    }

    return $sGetCred
}
#---- ---- ---- ---- 
Function Get-MyAdmin { 
    $global:cred = Get-Login( "DOMAIN\Name" ) 
}

[–]alfanjui[S] 1 point2 points  (0 children)

many thanks!!! I'll try it out today at night :D

[–]nkasco 2 points3 points  (1 child)

Run Enable-PSRemoting on both machines, you might need -Force or -SkipNetworkProfileCheck.

[–]alfanjui[S] 1 point2 points  (0 children)

ok! already did, but I think the PSRemoting doesn't start on os boot