Powershell Script Error - A specified Logon session does not exist - powershell

I am trying to export the STARTLAYOUT.XML file from Windows 10 computer. I issue the following command in Powershell which is logged in as a local admin user.
Powershell Admin
I enter the local admin username and password
Run the command >Export-Startlayout c:\startlayout.xml
Error
Export-Startlayout: A specified logon session does not exist. It may already have been terminated.
At line1 Char1
Any ideas guys. I have not had issues like this before. These are Autopilot Intune joined AAD devices.

Related

Permission/role required to run migration command

I am a Global Admin I can run set-moverequest in PowerShell.
I want to give another IT staff member permission so that he can also run this command to help me migrate users from the local exchange to exchange 365
What are the Roles in M365 which allow you to run this command?
Is there any way we can check in PS what Role is required to run any specific command?
P.S: my colleague has a Helpdesk Administrator role in M365, and he gets error when try to run the command.

Silent initdb.exe postgresql

I am trying to install postgresql on a server using a bat file. I am using initdb.exe with --pwfile option so that it picks up the password form a text file and continues...
for some reason, even with --pwfile option, it is still prompting me for a password.. Not sure what the problem is.. This is the script I am using:
set DBPATH = something
set DBADMIN = something
set DBDATA = something
RunAs /noprofile /user:%computername%\postgres ""%DBPATH%\initdb.exe" --locale=C --encoding=UTF-8 -U %DBADMIN% --pwfile="D:\Pass.txt" -D "%DBDATA%""
Thanks
If you want to install a software which requires for the installation administrator privileges and the current user account does not have the required privileges, it is possible to use command RunAs to run the installation executable and all processes started by this application with a different user account than the current user account which has the required privileges.
But the user has to enter nevertheless a password - the password for the other user account with the extended privileges to install applications. If it would be possible to run something requiring extended privileges for installing software without requesting entering the password by the user, every bad guy out in the world could very easily install trojaners and other malware (as it is possible on Windows 2000 / XP or since Windows Vista with user account control disabled).
There are systems to deploy and install software on all clients of a company like Group Policy or System Center Configuration Manager.

How to execute PowerShell script as local admin, but show results on logged-in users desktop?

Here is my scenario:
I have several computers all on the same domain. Users authenticate against the domain to log into their workstations.
All the local Administrator passwords on the workstations are the same.
What I want to do is execute script remotely using Invoke-Command so that I can create balloon-tip notifications on the users desktop. The problem seems to be that I have to execute the remote script as the local Administrator on each workstation, but I want the balloon tip to popup on the desktop of the logged in user.
Is there a way to do this?
I'm running PowerShell 3.0, but most of the target machines would be 2.0.

Problems using RunAs in TestComplete7

I have a problem with running RunAs mode in TestComplete7.
I use:
var p = TestedApps.MyApp.RunAs("domain", "user", "password");
but without success.
I get this error:
**************************************************
Unable to run "MyApp" under the Domain\User account.
Make sure that the password and other parameters are valid and you have sufficient rights to run processes under another user account.
**************************************************
I'm running TestComplete in Administrator mode and I've done everything as explained in TestComplete Help.
Check out this TestComplete support article for troubleshooting tips. Some key points from this article:
Is the Secondary Logon service running?
Are the domain, user name and password valid and spelled correctly?
Try Windows runas command with an arbitrary application (e.g. Notepad) and exactly the same credentials and see if it works.
Is the password non-empty? (Accounts with empty passwords aren't supported for RunAs in TestComplete.)
Does this account have permissions for actually executing the application?

Execute a remote process on a non-admin account using Powershell

I want to run aa remote process (winword.exe more specifically) from a remote machine using Powershell 2.0. One requirement is that the process is run by a non-admin user account. I'm able to run winword.exe if the user is part of the local administrator group on the remote machine, however when I remove it from the admin group, it fails - I get a winword.exe cannot be found error (32bit winword running on a 64bit 2008 server).
I've tried adjusting the PSSession configuration by granting the non-admin user account more elevated priveleges but it still fails:
Set-PSSessionConfiguration Microsoft.Powershell -ShowSecurityDescriptorUI
Is there something I'm missing here? Or does the user account explicitly require admin level priveleges on the server? Although PS tools would be a nice alternative, I would prefer using PS.
Have a look to the "Understanding Session Configurations" paragrph in the Administrator's guide to PowerShell Remoting from PowerShell.com.