run sharepoint powershell from c# on another PC? - sharepoint

If the C# application is on the same server as sharepoint, I know we can use RunSpace to run the pwoershell script, but what if the C# app. and sharepoint server are on different PCs?
Is this possible?
thanks

yes, its possible, though messy. In Powershell 2.0+, there's a feature called remote powershell, so you can effectively, via c# code, send Powershell commands to your local powershell instance, and use that to log into the remote instance.
A slightly less insane idea would be to simply create a web service on the remote machine, and have that run the remote powershell commands, from the web service.
And even less crazy idea is just to write a web service, and have that run code on the remote server. : )
Good luck!

If you are administrator on the remote box, you can try combining PsExec and PowerShell.

Related

Is there a Unix Expect Binary / Utility equivalent for Windows Batch or Powershell for interactive scripts?

I am trying mirror a process on Windows that I use on linux for creating an automated build of an application web server. The only way to have full automation is to have some sort of EXPECT utility for the interactions on the CLI.
We use a script to setup all the configuration and settings for our applications web servers that is easily portable to batch since the web server is windows compatible as well with the same commands.
I've basically got it down for Linux, however the flip side to this is that the windows doesn't seem to have a clear expect alternative.
Any suggestions to allow it to send a response when prompted and continue the rest of the scripted process would be most helpful.

Open Excel File on Azure VM with Powershell Script Sent from Local Computer

Can someone show how I can open an Excel document and show it visually on an Azure virtual machine using a Powershell script sent from my local machine? I have already figured out how to run Powershell script on the VM through the AzureVM module but am running into the issue of Windows not allowing remote Powershell users to interact with a user interface. Notes:
I have tried PSEXEC with no luck. This may be the way to go, but I have had no luck getting it to actually work.
I am not smart, so please use the most dumbed-down terminology as possible.
My end goal is exactly that stated above - nothing more nothing less.
Riches and honor to the one who can solve this.

How do I host a long-running task on a Windows web hosting?

I'm having a smarterasp.net windows web hosting. I need to have a service that runs permanently and periodically parses a specific remote website, writing results to a log file. I have created a windows servcice, but how do I host it on my web hosting? Running exe files is forbidden, as well as SSH.
Any help? Thanks.
As far as I have found out, it's often impossible to run a windows service on a web hosting, like in my case. One of the possible workarounds in hosting a background process in the website process, specifically by utilizing things like hangfire.io

Web frontend to my Powershell scripts for helpdesk

I'd like to have a web frontend to my powershell scripts for helpdesk.
These scripts would typically be user-creation scripts and scripts to restart a specific service on a specific server.
Where should I start? What would I need?
There is no problem for me to set up a IIS for this purpose if needed. We also have Sharepoint on a dedicated server.
Hoping for some startup-tips:)
You can consider Powershell Web Access feature on Powershell V3.0
http://technet.microsoft.com/en-us/library/hh831611.aspx
This is a robust solution, factoring in IIS, security and shell access.
You can use PowerShell Remoting. You can open a PS session that would look like a local PS console to you but it would be running on the remote machine. You can type PS code to be executed remotely and launch a buch of ready-to-run ps1 scripts for SP administration there too. Have a look at those links, for example:
http://www.computerperformance.co.uk/powershell/powershell_remote.htm,
http://blogs.technet.com/b/heyscriptingguy/archive/2011/11/17/learn-how-to-manage-remote-powershell-sessions.aspx
--- Ferda

Give webservice access to windows service

I am running a webservice on server 2008 that needs access to a windows service and I need to give access to [the user that the web service is running as] via the command line.
(sorry if my wording is terrible, hopefully the brackets helped?).
I know there is a utility available with the windows 2000 resource kit (SUBINACL.exe), but is there one available in server 08 that doesn't require downloading a resource kit?
Thanks.
For everyone else wondering how to do this...
Microsoft offers a utility available for download called Subinacl.exe that allows you to do just this.
subinacl.exe /service <serviceName> /grant=Domain\AccountName=<AccessType>
For info on the different access types and on the utility in general...
subinacl.exe /help /full

Resources