I am a newbie in powershell script. I want to uninstall a service on remote machine and re-install it again. I am able to stop the service, change the files that service is using and again start it.
But, now I want to completely uninstall it.
One more thing, I will be executing these scripts via TeamCity.
I have tried following ways, but each one is giving trouble:
using wmi class
running installutil command on remote machine. But, cant execute this on remote machine since there is problem in accessing that service.
Using Get-WmiObject command and then calling delete() on retrieved service.
Is there any promising solution ??
Any help will be appreciable..
After playing a lot with TC and many commands, finally I got my answer to uninstall a service on remote computer, and its working properly.
I have made use of "wmic" command and provided the remote computer name, username and password for /node:, /username:, and /password: parameters. And, provided 'installutil.exe' command to be executed remotely. Here, the actual command is..
"wmic /NODE:$serverName /USER:$userName /PASSWORD:$password process call create '$path_to_installutil_exe\installutil /u $exe_location_path_of_service'"
Related
I'm having an issue with the Print Spooler getting hung up on a Hyper-V server that im running and tickets get hung up...Im just trying to streamline this by figuring out how i can just run a powershell script without having to enter any credentials manually. I can get a powershell script to accomplish this but the only one that i have found implements the Get-Credentials and prompts to enter credentials then i get put into a remote Powershell session on the server where i can restart the service from there.
Is there an easier way to accomplish what i am trying to do?
I have some Powershell scripts for deploying our applications to test machine. These have to be executed using Invoke-Command from the developer machine. Is there anyway to log host machine name/IP from which these scripts are called.
For example:
If developer foo deployed an application using the script from devmachine1 i want to get the name/IP of the devmachine1 and log it in our test machine.
We are using Powershell V4.0. Can upgrade to 5.0 if required.
answering this to mark the question as solved. just incase if some one is looking for an answer.
I am passing computer name $env:COMPUTERNAME as a parameter to the remote script.
Getting the remote username using $PSSenderInfo.ConnectedUser in the remote script.
If we assume that a service must be run as administrator, is it possible to install it using a command line (sc.exe, powershell - all is available)?
Bonus: Is it possible to do without providing password?
sc.exe config 'servicename-notdisplayname' obj='\Administrator' password='secret'
Still no luck avoiding password, as it's required when starting the service.
I am facing a very strange issue trying to run a Remote PowerShell script from the new build system of Visual Studio Online.
Context:
I have a Build server that I host on my own VM. I have also created a second VM where I want the PowerShell script to be run on.
When I run a build from the Build server, I want to create a task that run a PowerShell script on a remote machine. Sounds easy.
Both machines have everything configured to run the Remote PowerShell. (I think)
Problem:
If I manually run the script from the build server, the script is properly executed on my remote machine.
But, if I run the script by starting a new build, it doesn't work, I always get an error message
New-PSSession : [xxx.cloudapp.net] Connecting to remote server xxx.cloudapp.net failed with the following error message : Access is denied. For more information, see the about_Remote_Troubleshooting Help topic.
Have you faced this issue before with VSOnline?
This can happen if there isn't a trust relationship between the remote machine and the build machine. E.g. you could look at the hosts.equiv file on the remote machine and make sure it trusts the build machine.
If that doesn't help then more info might be needed, like how you're trying to sign in, what build agent account you're running as.
Guy
As the title describes I need to run a command on a remote server and I do not have access to remote desktop! I head that this should be possible using Powershell, but I can't find any good tutorials on this.
Recommendations?
The easiest way is to use psexec.exe (Part of Microsoft Sysinternals).
You can also use powershell.
I wrote a blogpost about these two alternatives a few days ago:
http://blog.degree.no/2012/03/executing-commands-and-programs-on-a-remote-machine-using-powershell/
When using PSEXEC or PowerShell remoting you can execute a command on a remote machine, but it is not interactive with any currently logged on user. Using PowerShell requires 2.0 to be installed on your machine and remotely AND remoting must be enabled AND you must have admin rights on the remote computer.