Launch local PowerShell script from link in local browser session - powershell

My boss has asked me to look into launching a PowerShell script I've written (which is to be deployed to all users desktops) when the user clicks on a link in their web browser (and not by the clicking on a desktop icon as I've proposed). I did not think this was possible for security reasons and can't understand how this can be done. Does anyone know if this is possible ? i.e. a web link can somehow trigger the running of a PowerShell script held locally on the user's machine? Seems dangerous to me but he says it can be done !!!

No, it won't automatically run a linked script and will require the user to download and then run it.
The way to accomplish the goal of running a script when they click on something, though, would be to do it with server-side code that launches the script remotely or creates a scheduled task on the user's system. However, this may not work if the user needs to see the command window or interact with the script.

Related

How to fix msedgewebview2 error in VS2022 when admin?

I have installed the relatively fresh Visual Studio 2022 on a Windows installation. The work I do often requires administrative privileges (local IIS). To do this I have two users, one 'normal' account that is logged in to Windows and one administrator account. When starting VS2022 with the administrator account, an error keeps coming. It happens especially during debugging and it reads as follows:
Microsoft Edge can't read and write to its data directory:
C:\Users\<administrator_user>\AppData\Local\Temp\VSWebView2Cache\<guid>\EBWebView
What appears to happen is that Microsoft Edge WebView2 (msedgewebview2.exe) is running as the user that is logged in to Windows, while trying to write temporary files for the administrator user where it does not (and should not) have write or read access.
Here we can see the process details that says the application user is the logged in user and not the administrator:
Does anyone know how to fix this issue?
The error happen even when I run debugging on a .net 5 console application. In that particular situation I don't see why it needs to run anything in a WebView instance, but apparently some background process is running something anyway. Is this something that can be turned off?
My best solution so far is to create a shared folder.
I decided to make C:\Users\<administrator_user>\AppData\Local\Temp\VSWebView2Cache\ shared. The "VS" prefix indicates that this is a Visual Studio-specific folder, and I think it is acceptable that my normal user can have access to that folder as it seems to contain temporary Visual Studio files.
To do so I logged in to Windows with the administrator account.
I navigated to the folder and made it a shared folder. I added my no-admin user with "Read/Write" privileges.
I then tested by logging out of the admin account and into my no-admin account. There I first tried the full path in File Explorer and was granted access to the folder. I then tested with VS2022 and during debugging no error box appeared and files were generated in the folder.
If anyone finds a better approach, I'd really like to hear about it. Also if you have knowledge to why this approach is either good or bad, that would be highly appreciated as well.
I only had to create the folder "VSWebView2Cache" with my normal Windows account and after that it worked.

How to run scheduled Coded UI Tests on Virtual Machine without having a RDP connection

Situation in short:
Virtual Machine with Visual Studio 2013 installed. PowerShell script
runs on the VM to execute Get Latest, Build and Execute Coded UI
Tests. Windows Scheduled Task to execute PowerShell nightly.
auto-logon is enabled (or I'm doing something wrong?)
yes, I've read post Is it possible to run Coded UI tests without having to connect via remote desktop?
I've seen posts about TCM. Does this help and how can I use it in my
situation?
I made some tests in Microsoft Test Manager and I also executed and recorded them.
I've loaded these tests in a test project (and changed the script providing categories and custom checks).
I then categorized these (as Development or Acceptance).
I executed out using a PowerShell script on a VM (with Visual Studio 2013 installed) with following actions:
Get Latest
Build
Run latest build with a selected set aka category using mstest.exe
So far everything is going perfectly. All the tests pass.
However, when I create a Scheduled Task on my VM run the PowerShell script everything fails because of a missing session.
Do I have the VM (I have no knowledge of Virtual Machines) then unlock or something?
Side-Note:
I also tried to fix this with a Test Agent and Controller, but once I had installed these, all other users of TFS lost their rights, so I prefer not to do this again.
I would be very grateful if you know something that can solve this.
I spent hours on Google finding a solution for this issue, but no solution helped me.
Do I need to provide more information?
The problem you're seeming to have is that the testagent is not setup correctly. You need an active desktop session for Coded UI to be able to run (it needs it to perform all the actions such as clicks).
Microsoft has some nice info about setting up your test agent here.
But to tackle your exact problem of the test failing because of a missing session I'd suggest the following:
Run AutoLogOn.exe from the sysinternals suite (can be found at http://live.sysinternals.com/). It will automatically log in with specified user when the machine starts, and keeps the desktop session active.
Alright...I'm making progress.
I've installed test agent and controller. It's all running fine.
Next I've opened Lab Center on my own MTM to create a new environment.
Test Controller is found, but I receive the message in this post "Microsoft Test Manager cannot install test agent on these machines" when creating new Lab Center environment
File and Printer sharing exception is enabled. I don't get the other message.
I don't understand what is wrong.
Maybe I'm completely on the wrong track and it's not necessary to use the Lab Center.
Then the only remaining issue is the non-active desktop issue.

Automated execution of a powershell script on Active Directory, Triggered from a web page

I am proposing an idea for a final year project that is basically a virtual environment. I would be using Citrix XenServer in conjunction with Windows Server 2008 R2 and Citrix netscaler to make the server accessible over the web. I would also be hosting a website on the server that Windows is on.
What I was wondering is, would it be possible to trigger the execution of a script on the server from the web page. So basically a user comes along, goes to my website, registers their details. a csv file is then produced based on the details that are input. Then I was wondering is there a way to trigger the execution of a powershell script that would use the csv file to set up the user in Active directory. The powershell script itself is simple its just how I would get it to run is another thing.
Yes it is possible.
PowerShell lets us create graphical interfaces with the .NET winforms. With it, we can build front end to manage our scripts. It's a really nice feature, and tools like AdminScriptEditor make it pretty easy.
I have found this link for your reference - PowerShellOnWebPage
You can tweak/create the script as per your need.
Let me know if this helps.
Thanks!

Windows 7 - Eclipse now needs me to run as administrator

I installed Eclipse (Kepler) on this W7 64-bit machine and initially I could run it "normally" by just clicking the desktop icon or whatever.
Then I replaced the whole "workspace" directory with one from another machine (because I'm changing systems).
Now if I run Eclipse not "as administrator" it opens and will even run apps... but nothing can be saved, including changes to files and updates to the .metadata of any kind.
I changed all the "ownership" and "permissions" which could possibly be involved. I am the only user of this machine, and I am in the administrators group. I CAN still use it, if I run "as an administrator". But I'm stumped why the UAC should have been happy to run Eclipse before without the "as 'strator" but now refuses...
Because... what I've understood about this question is that the UAC looks at apps and decides whether or not they look dodgy and on that basis decides whether you have to run "as 'strator". So what's changed?
I have the option of uninstalling Eclipse and reinstalling it, and then incrementally adding the various project folders... fine, it may work. But I like to understand these things as far as is feasibly possible!
Because... what I've understood about this question is that the UAC looks at apps and decides whether or not they look dodgy and on that basis decides whether you have to run "as 'strator".
UAC doesn't do anything like that. UAC is an ability of Windows to run an application as an administrator. There are three four ways an application can be run as an administrator (causing the UAC consent dialog to appear):
you right-click the application and select "Run As Administrator"
the application has been manifested with a requestedExecutionLevel of requireAdministrator
the application has a filename that looks like a setup application (e.g. setup.exe, install.exe, update.exe), in which case the Shell opts to run it elevated just in case
you call ShellExecute with the runas verb.
i think there's one of two things happening:
you missed a spot, in which case you should use Process Monitor to look for Access denied errors
you tried copying files to a protected location (e.g. Program Files) and they were instead redirected to:
C:\Users\Mike\AppData\Local\VirtualStore\Program Files(x86)\Eclipse
And then when you run Eclipse, the files are not there.
Again, use Process Monitor to find where Eclipse is looking for what.

Getting WatiN.Core.Exceptions.TimeoutException while running from CruieControl

I am getting WatiN.Core.Exceptions.TimeoutException:
Timeout while Internet Explorer busy error while executing my tests via CruiseControl.Net.
Any one have idea how to resolve this?
While we are using TeamCity, we had to disable IE protected mode.
Also, check that user, under which watiN tests are being run can interact with desktop.
I know this question is old and answered, but below are some of my observations.
It is possible to run watin tests under a service account
but the following restrictions/prerequisites apply:
service must run in desktop interactive mode. Only available if running as system.
tests must not create a new windows, even alert/confirm dialogs
Ie cannot create a new window, so watin fails when looking for/expecting it to appear.
ie may show its own warnings, e.g. Insecure content in a secure Page, this can cause tests to fail*
if the tests fail/timeout and the ie instance is forcefully closed, the next instance may try to restore the previous state. The tests then appear to fail*
this can be turned off in the advanced settings.
*from what I've experienced, usually because the prompt is halting the document from being reported as loading-finished.
Feel free to add with other restrictions /comments.