Using C# to run PowerShell command to create VirtualDirectory fails
I can run these commands with no problem directly in PowerShell. But trying to get C# to run them, I receive errors.
md d:\ftproot\vdir\test20140317A;
New-WebVirtualDirectory -Site "[site]/[a virt directory]" -Name test20140317A -physicalPath d:\ftproot\vdir\test20140317A;
When running in c# through two different means, I receive these errors
Exception:Caught: "A parameter cannot be found that matches parameter name 'physicalPath'." (System.Management.Automation.CmdletInvocationException)
A System.Management.Automation.CmdletInvocationException was caught: "A parameter cannot be found that matches parameter name 'physicalPath'."
Though in Visual Studio , there's something called InteliTrace and it's showing a whole slew of exceptions starting with
Exception:Thrown: "Unable to load DLL 'wldp.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)" (System.DllNotFoundException)
A System.DllNotFoundException was thrown: "Unable to load DLL 'wldp.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)"
Exception:Thrown: "Requested registry access is not allowed." (System.Security.SecurityException)
A System.Security.SecurityException was thrown: "Requested registry access is not allowed."
Exception:Thrown: "Cannot find path 'C:\Users\jpacella\Documents\WindowsPowerShell\Modules' because it does not exist." (System.Management.Automation.ItemNotFoundException)
A System.Management.Automation.ItemNotFoundException was thrown: "Cannot find path 'C:\Users\jpacella\Documents\WindowsPowerShell\Modules' because it does not exist."
Exception:Thrown: "Could not load file or assembly 'Microsoft.IIS.PowerShell.Framework' or one of its dependencies. The system cannot find the file specified." (System.IO.FileNotFoundException)
A System.IO.FileNotFoundException was thrown: "Could not load file or assembly 'Microsoft.IIS.PowerShell.Framework' or one of its dependencies. The system cannot find the file specified."
Exception:Thrown: "Cannot find path 'C:\Users\jpacella\Documents\WindowsPowerShell\Modules' because it does not exist." (System.Management.Automation.ItemNotFoundException)
A System.Management.Automation.ItemNotFoundException was thrown: "Cannot find path 'C:\Users\jpacella\Documents\WindowsPowerShell\Modules' because it does not exist."
Exception:Thrown: "Process should have elevated status to access IIS configuration data." (System.InvalidOperationException)
A System.InvalidOperationException was thrown: "Process should have elevated status to access IIS configuration data."
Exception:Thrown: "Object reference not set to an instance of an object." (System.NullReferenceException)
A System.NullReferenceException was thrown: "Object reference not set to an instance of an object."
Exception:Thrown: "Cannot find drive. A drive with the name 'IIS' does not exist." (System.Management.Automation.DriveNotFoundException)
A System.Management.Automation.DriveNotFoundException was thrown: "Cannot find drive. A drive with the name 'IIS' does not exist."
Exception:Thrown: "" (System.Management.Automation.ParameterBindingException)
A System.Management.Automation.ParameterBindingException was thrown: ""
Exception:Thrown: "The pipeline has been stopped." (System.Management.Automation.PipelineStoppedException)
A System.Management.Automation.PipelineStoppedException was thrown: "The pipeline has been stopped."
Exception:Thrown: "A parameter cannot be found that matches parameter name 'physicalPath'." (System.Management.Automation.CmdletInvocationException)
A System.Management.Automation.CmdletInvocationException was thrown: "A parameter cannot be found that matches parameter name 'physicalPath'."
These are the two different ways I invoked the script
PowerShell ps = PowerShell.Create();
ps.AddCommand("New-Item")
.AddParameter("Path", newPathName)
.AddParameter("ItemType", "directory");
ps.AddStatement().AddCommand("New-WebVirtualDirectory")
.AddParameter("Site", Properties.Settings.Default.VirtualDirectoryPath)
.AddParameter("Name", userName)
.AddParameter("physicalPath", newPathName);
ps.Invoke();
and (scriptContents is a string holding the
Runspace runspace = RunspaceFactory.CreateRunspace();
runspace.Open();
Pipeline pipeline = runspace.CreatePipeline();
pipeline.Commands.AddScript(scriptContents);
pipeline.Commands.Add("Out-String");
Collection<PSObject> results = pipeline.Invoke();
runspace.Close();
I tried yet another way to make a Virtual Directory:
public void CreateVirtualDirectory2(string userName, string password)
string newPhysicalPathName = Path.Combine(Properties.Settings.Default.PhysicalPathForVirtualDirectory, userName);
StringBuilder sb = new StringBuilder();
if (Directory.Exists(newPhysicalPathName) == false)
sb.AppendLine(@"md " + newPhysicalPathName);
sb.AppendLine("cd iis:");
sb.AppendLine("cd Sites");
sb.AppendLine("cd ftp");
sb.AppendLine(@"New-Item 'IIS:\Sites\ftp\bridgenet\" + userName + @"' -Type VirtualDirectory -physicalPath " + newPhysicalPathName);
string script = VirtualDirectoryScript(sb.ToString());
RunspaceInvoke invoker = new RunspaceInvoke();
try
invoker.Invoke(script);
catch (Exception e)
Console.ForegroundColor= ConsoleColor.Black;
Console.BackgroundColor = ConsoleColor.Red;
Console.WriteLine("ERROR: " + e.Message);
Console.ResetColor();
And the same exception occurs
"A parameter cannot be found that matches parameter name 'physicalPath'."
When I run the script outside of C#, there's no error.
So no one's responded yet , which is pretty disappointing.
Similar Messages
-
Administrator Unable To Run Powershell Commands When UPD Enabled
Hi All,
We have a single Windows 2012 R2 RDS configured with UPD enabled for the defined collection. So far everything is working fine for standard users; however, the domain administrator can no longer run PowerShell commands (see attached screenshot).
I believe this is the result of the UPD "impersonating" the local c:\. How can I get around this for domain administrator accounts?
Thanks in advance.Hi,
By UPD, you mean user profile disk, right?
In addition, all non-administrator users can run the exact same PowerShell cmdlet, right?
What about other PowerShell cmdlets, are administrators able to run them?
Best Regards,
Amy
Please remember to mark the replies as answers if they help and un-mark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected] -
Run powershell commands on a bat file
Hello,
I can call powershell on command line as below:
C:\>echo I am in Command Shell
I am in Command Shell
C:\>powershell
Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.
PS C:\> Write-Host I am in Powershell
I am in Powershell
PS C:\> exit
C:\>echo I returned to Command Shell
I returned to Command Shell
But I want to create a bat file and run these commands in bat file. To do this, I copied and pasted same codes to Test.bat file:
echo I am in Command Shell
powershell
Write-Host I am in Powershell
exit
echo I returned to Command Shell
But after "powershell" command nothing worked as below:
C:\>.\Test.bat
C:\>echo I am in Command Shell
I am in Command Shell
C:\>powershell
Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.
PS C:\>
I want this output:
I am in Command Shell
I am in Powershell
I returned to Command Shell
How can I handle this problem.
PS: I don't want to use powershell file (*.ps1).
ThanksIn my Test.bat file there are some commands. My Test.bat file is sth like this:
@echo off
echo I am in Command Shell
powershell.exe
Write-Host I am in Powershell
$Var = "Some words"
Write-Host My ID: $Id, String: $Var
exit
echo I returned to Command Shell
There are other different commands, such as importing modules or setting variables or configuring computer settings,.... So, I think "powershell -command" is not applicable.
In brief;
Above codes work in command line.
But when I use same codes in a batch file, nothing works in powershell. Result is sth line this:
C:\>Test.bat
I am in Command Shell
Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.
PS C:\> -
Run powershell command in app part on submitting item in O365 Sharepoint list.
I need to fire an powershell command through app part as soon as i have submitted details or form on the list.
As powershell command requires inputs, i have created list and a form into it, i mapped the column with the powershell input, but the commands is not running or firing, please help.
Regards
Mohit JainHi,
According to your description, my understanding is that you want to run a Powershell command when submitting a form on the list to create mailbox for user.
As your environment is Office 365, I suggest you can create a web service to call the PowerShell Command using C#. Then in the office 365 list, you can create a remote event receiver to trigger the web service to
achieve it.
Here are some detailed articles for your reference:
http://msdn.microsoft.com/en-us/library/ms464040%28v=office.12%29.aspx
http://www.codeproject.com/Articles/18229/How-to-run-PowerShell-scripts-from-C
http://msdn.microsoft.com/en-us/library/office/jj220043(v=office.15).aspx
Best Regards
Forum Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
[email protected]
Zhengyu Guo
TechNet Community Support -
Running Powershell command from PHP returns blank page
Hi. :-)
I have this script :
<?php
$q = shell_exec('powershell Get-Help');
echo $q;
?>
This works well and gives me output.
But... When I change Get-Help with Get-VM it gives me blank page as ouput. I have simillar problems with other Hyper-V cmdlets.
This is code 1:
<?php
$q = shell_exec('powershell Get-VM');
echo $q;
?>
This code gives me blank page.
Code 2:
<?php
$q = shell_exec('powershell Start-VM 'Vm1'');
echo $q;
?>
This code gives me that it cannot find VM with that name.
What's the problem, what to change in script or system settings.
Note: All this commands WORK and gives me output when I run it from cmd
Things that I did:
1. Changed execution policy to Unrestricted
2. Added 2<&1 at the end of shell_exec.
Thanks in advance.Hi,
I think we should run powershell as adminitrator to get VMs.
Start-Process "$psHome\powershell.exe" -Verb Runas -ArgumentList '-command "Get-VM"'
Regards,
Yan Li
Regards, Yan Li -
Using the "Run Powershell command" in Task Sequence
Hi,
We are having problems executing PowerShell Scripts from within a TaskSequence. We use this to perform different actions on our servers.
* We have a GPO for Windows PowerShell that is set to "allow all scripts"
* In Sccm, the computer agent setting is set to "bypass"
*In the deployement we specify that we want to run the content from the DP
When we run the TaskSequence, powershell is started but the script is not executed. The TS is stuck at this time and is just waiting for the script to execute... After killing the powershell process, the TS failes (of course).
How can we get this working:
-by disabling the GPO -> indeed then it works
-by downloading the content locally (we don't want that either)
Is there any other solution to this?
I've also tried this but no go:
Quote:
Please note, that this policy will only work for scripts which are executed locally. If you want to execute ps1 scripts from a network drive it might be neccessary to add the dp server name into the trusted sites of the IE!
Source:http://social.technet.microsoft.com/Forums/en-US/a2d44774-a352-40f6-93be-037ccf0bc98b/not-able-to-execute-powershell-scripts-when-running-a-task-sequence-or-running-from-packageprogram?forum=configmanagersdk
I also tried to run it via the command line option and call powershell.exe, same problem. Executing a scriptblock on the other hand does work. (In the scriptblock, it put get-executionpolicy and it is returning unrestricted)
Thanks,
WiM
IC3CUB3Add below to .ps1 file
$session = New-pssession
Import-PSSession $session
New-ItemProperty 'HKLM:\Software\Microsoft\Windows\CurrentVersion\AutoRotation' -Name Enable -Value 0 -PropertyType Dword"
Schedule task
================
Program to choose
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
add argument section
powershell.exe -noprofile -executionpolicy bypass -file \\server\file.ps1 -
SCCM 2012 SP1 - PowerShell command to create a software update group deployment DISABLED by default
Hello,
I create deployment jobs using new Powershell cmdlet "Start-CMSoftwareUpdateDeployment". However it looks there is no way with this cmdlet to create a job which is disabled by default.
Is it possible ? As an alternative, which cmdlet could I use to manage enable/disable job state ? I have not found anything so far.
Regards.
Sylvainhi, i tried the solution to create a deployment using http://cm12sdk.net/?p=2014 link.
it creates deployment but it is not downloaded so a red cross sign is shown in front of software update group. can you guide me on which command to use to download software update after which we can try the script mentioned in the link.
thanks.
-
[Solved] stumpwm: how to get rid of newline using run-shell-command
Hi all,
in order to set up my mode-line for stumpwm, I've been using the commad
run-shell-command such as in:
(setf *screen-mode-line-format*
(list
'(:eval (run-shell-command "date" t))
'(:eval (run-shell-command "date" t))))
However, each instance of run-shell-command creates an unnecessary
newline (so that my mode line contains two lines without necessity).
Do you know how I can get rid of this newline?
Thanks!
Last edited by falsum (2011-05-23 07:12:27)jiyuu wrote:
I didn't test it but the function you want is 'string-trim' or 'string-right-trim'.
You use it like this:
(string-trim '(#\Newline) my-string)
So in your case:
(setf *screen-mode-line-format*
(list
'(:eval (string-trim '(#\Newline)
(run-shell-command "date" t)))
'(:eval (run-shell-command "date" t))))
That works perfectly well. Thanks a lot jiyuu!! -
Run Powershell Script task sequence
Hi,
Anyone have good documentation on how to use the Run PowerShell Script task sequence ?
ThanksIf you are just interested in running a powershell command without creating a package, you can do this with the the Command line step by using this format in the command line:
PowerShell -ExecutionPolicy bypass -Command "& {your powershell commands}"
Here is an example of a multiline command to increase the agents cache size. Notice the ";"'s which are used to delineate a new line.
PowerShell -ExecutionPolicy bypass -Command "& {$UIResourceM gr = New-Object -ComObject UIResource.UIResourceMgr;$Cache = $UIResourceMgr.GetC acheInfo();$Cache.TotalSize = "20480"}" -
Cannot follow the manual powershell instructions to create a W2Go Device
Hi,
I tried to use the native Windows To Go creator wizard in my Windows 8.1 Enterprise edition. My USB flash drive was a Patriot 32 GB one of RAGE type. It was the best product found in our local market, as the Microsoft recommended devices were not available
to purchase. Unfortunately, the wizard failed to start with my flash drive and refused to work with it.
Then, I found a page on TechNet through google (http://social.technet.microsoft.com/wiki/contents/articles/6991.windows-to-go-step-by-step.aspx) which showed me a step-by-step guide to create a Windows To Go drive using a list of PowerShell
commands. It requires you to create two separate partitions on the drive and execute some instructions to make it. The surprising point that I realized was that the Windows does not allow you to have access to more than one primary partition at a time on the
Removable disks. This meant for me that the powershell script was not applicable to my flash.
I also tried to make a trick and used BootIce software to swap accessible partitions. But, I could not link the two partitions so that the Windows boots from the device.
My first question is: Does Microsoft certified W2G devices bypass the restrictions mentioned above on simultaneous access to flash drive partitions?
Second question: How to logically link the two partitions stated above so that the drive can boot successfully any system? Am I wrong with the process?
ThanksHello sisili,
Are you confused about the two partition?
The 350 MB partition is system partition , and the other is OS partition.
Based on my knowledge, the certification process ensures that drives are built for the high random read / write speeds required for running Windows smoothly. In other part, they are same.
For more information, please take a look at the following video about how to create a Windows To Go Workspace.
https://technet.microsoft.com/en-us/windows/dn127075.aspx?f=255&MSPPError=-2147217396
It give the steps about create Windows To Go by by using the Create a Windows To Go Workspace wizard.
And then analyze the how to use Windows PowerShell.
Best regards,
Fangzhou CHEN
Fangzhou CHEN
TechNet Community Support -
PowerShell command To configure Access Service 2010 in sharepoint 2013 server
HI ,
can any body give reference for Powershell command for
Access Service 2010
I am currently able to run powershell command for
Access Service .
But in sharepoint 2013,Access Service 2010 is a new service, but i am not able to see any refernce blog for command.Hi,
According to your description, you want to configure Access Service 2010 in SharePoint 2013 server by using a Windows PowerShell.
Take a look at an articles about configuring services and service applications in SharePoint 2013:
http://technet.microsoft.com/en-us/library/ee794878(v=office.15).aspx
Updates on how to do a lot of these (include
configure Access Service 2010 ) with PowerShell haven't really been released yet.
Here is an article about configuring a service application by using a Windows PowerShell script (SharePoint Server 2010), you can use as a reference:
http://technet.microsoft.com/en-us/library/gg983005(v=office.14).aspx
Best Regards,
Lisa Chen
Forum Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
[email protected]
Lisa Chen
TechNet Community Support -
Run PowerShell script from C# writing to input pipe
Hello,
I am trying to run a PowerShell script from C# (I have no control over what's in the script). The script may have a prompt like "Press enter to continue". So my goal is:
1. Get text output from the script (easy, many examples available)
3. If output contains "Press enter to continue", write a blank line to the running script's pipe to make it finish its job and quit
4. If output does contain that prompt, just let it exit by itself without sending any input
Note that commands in this PS script also try to get at script's file path, so I can't read script from file and pass it as text. It has to be executed as a script so it knows where it's located.
I have done this with .exes and batch files before. All you do in that case is process.StandardInput.WriteLine() which "types" enter into the input stream of script you are trying to control. But this does not work with Power Shell. How do I do this?
I have tried using PS object model like so:
using (Pipeline pipeline = runspace.CreatePipeline())
Command command = new Command(scriptPS, true, true);
pipeline.Commands.Add(command);
pipeline.Commands[0].MergeMyResults(PipelineResultTypes.Error, PipelineResultTypes.Output);
pipeline.Input.Write("\n");
Collection<PSObject> psresults = pipeline.Invoke(); //...
But I get an error because the script prompts:
"A command that prompts the user failed because the host program or the command type does not support user interaction. Try a host program that supports user interaction, such as the Windows PowerShell Console or Windows PowerShell ISE, and remove prompt-related
commands from command types that do not support user interaction, such as Windows PowerShell workflows."
I also tried using Process, and running PowerShell with -File switch to execute the script, then write to StandardInput with C#. I get no errors then, but the input is ignored and doesn't make it to PowerShell.
Please help!No man, what kind of answer is that? You should have left it unanswered rather than waste people's time like this. I already seen those links before I posted my question. They address the issue of specifying script parameters, but not
writing to the input pipe.
Fortunately I did figure this out by writing a custom script host for PowerShell. Anyone interested can read about this in detail on MSDN (fortunately simple material with samples you can copy paste as I did, so this solution takes little time to implement).
Implement PSHost interface. Nothing special here, just paste directly from MSDN sample and modify their SetShouldExit function definition to contain just a "return;". Here's the relevant link:
http://msdn.microsoft.com/en-us/library/windows/desktop/ee706559(v=vs.85).aspx
Implement PSHostUserInterface interface. This is the ticket to solving this problem
(see below). Here's the MSDN link:
http://msdn.microsoft.com/en-us/library/windows/desktop/ee706584(v=vs.85).aspx
Implement PSHostRawUserInterface. This may not be required (not sure) but I did anyway. Nearly a direct paste from MSDN:
http://msdn.microsoft.com/en-us/library/windows/desktop/ee706601(v=vs.85).aspx
So, there are two PSHostUserInterface function implementations that are of particular interest. First is Prompt (read header comment to see why):
/// <summary>
/// When script attempts to get user input, we override it and give it input programmatically,
/// by looking up within promptInput's dictionary<string,string> or lineInput array.
/// PromptInput dictionary is mapped by input prompt (for example, return "" in response to "Press ENTER to continue")
/// LineInput is a regular array, and each time the script wants to prompt for input we return the next line in that array;
/// this works much like piping inputs from a regular text file in DOS command line.
/// </summary>
/// <param name="caption">The caption or title of the prompt.</param>
/// <param name="message">The text of the prompt.</param>
/// <param name="descriptions">A collection of FieldDescription objects that
/// describe each field of the prompt.</param>
/// <returns>Throws a NotImplementedException exception.</returns>
public override Dictionary<string, PSObject> Prompt(string caption, string message, System.Collections.ObjectModel.Collection<FieldDescription> descriptions)
Dictionary<string, PSObject> ret = new Dictionary<string, PSObject>();
foreach (FieldDescription desc in descriptions)
if (this.promptInput.Count != 0)
ret[desc.Name] = new PSObject(this.promptInput[desc.Name] + "\r\n");
else if (this.lineInput != null && this.currentLineInput >= 0 && this.currentLineInput < this.lineInput.Length)
ret[desc.Name] = new PSObject(this.lineInput[this.currentLineInput++] + "\r\n");
else
if (desc.DefaultValue == null)
ret[desc.Name] = new PSObject("\r\n");
else
ret[desc.Name] = new PSObject(desc.DefaultValue);
return ret;
Next is PromptForChoice. Here I opted to always return the default choice, but you could rewrite it to read from somewhere to "simulate" reading from input pipe just like the function above:
public override int PromptForChoice(string caption, string message, System.Collections.ObjectModel.Collection<ChoiceDescription> choices, int defaultChoice)
return defaultChoice;
Last but not least, here's a ReadLine implementation (again read header comment):
/// <summary>
/// If the LineInput is set, "read" the next line from line input string array, incrementing line pointer/// </summary>
/// <returns>The characters that are entered by the user.</returns>
public override string ReadLine()
if (this.lineInput != null && this.currentLineInput >= 0 && this.currentLineInput < this.lineInput.Length)
return this.lineInput[this.currentLineInput++];
else
return Console.ReadLine();
Both are exposed as properties:
/// <summary>
/// Gets or sets the input pipe override
/// </summary>
public string Input
get
return string.Join("\n", this.lineInput);
set
if (value != null)
this.lineInput = value.Split('\n');
this.currentLineInput = 0;
else
this.lineInput = null;
/// <summary>
/// Gets or sets input pipe override for named prompts
/// </summary>
public Dictionary<string, string> PromptInput
get
return this.promptInput;
set
this.promptInput = value;
And finally, here's how the whole shebang is used:
/// <summary>
/// Runs a powershell script, with input pipe arguments
/// </summary>
/// <param name="script">Path of the script to execute, or script text</param>
/// <param name="inline">Whether or not to execute script text directly, or execute script from path</param>
/// <param name="unrestricted">Whether or not to set unrestricted execution policy</param>
/// <param name="parameters">Parameters to pass to the script command line</param>
/// <param name="inputOverride">Input to pass into the script's input pipe</param>
/// <param name="inputOverrideName">Input to pass into the script's input pipe, to each prompt by label</param>
/// <returns>Output lines</returns>
public static string PowerShell(string script, bool inline, bool unrestricted = false, Dictionary<string, string> parameters = null, string inputOverride = null, Dictionary<string, string> inputOverrideByName = null)
string output = null;
ScriptHost host = new ScriptHost();
(host.UI as ScriptHostUserInterface).Input = inputOverride;
(host.UI as ScriptHostUserInterface).PromptInput = inputOverrideByName;
using (Runspace runspace = RunspaceFactory.CreateRunspace(host))
runspace.Open();
if (unrestricted)
RunspaceInvoke runSpaceInvoker = new RunspaceInvoke(runspace);
runSpaceInvoker.Invoke("Set-ExecutionPolicy Unrestricted");
using (Pipeline pipeline = runspace.CreatePipeline())
if (inline)
pipeline.Commands.AddScript(script);
else
Command command = new Command(script, true, true);
foreach (KeyValuePair<string, string> param in parameters)
command.Parameters.Add(param.Key, param.Value);
pipeline.Commands.Add(command);
pipeline.Commands.Add("Out-String");
pipeline.Commands[0].MergeMyResults(PipelineResultTypes.Error, PipelineResultTypes.Output);
Collection<PSObject> psresults = pipeline.Invoke();
var sb = new StringBuilder();
foreach (PSObject obj in psresults)
sb.AppendLine(obj.ToString());
output = sb.ToString();
pipeline.Dispose();
runspace.Close();
return (host.UI as ScriptHostUserInterface).Output + "\r\n" + output;
As you can see, I also did some magic with the .Output property. That just accumulates lines of text output by the script in every WriteXXX function implemented in your custom PSHostUserInterface. The end result of all this, is that if you have a script
that has prompts, choices or reads from standard input, you can execute the script within the context of your custom script host written as above, to control precisely what strings are passed to it in response to prompts.
-
Execute powershell commands on a VM from the host.
I’m wondering if it’s possible to execute PowerShell commands from the host that will be execute on a virtual machine.
I have around 10 VM and I need to run the same command on all of it and I need to do the same in other 15 host.
None of the VM belong to the same domain.Yes, it's possible.
It's not recommended to do any administrative tasks from the host. You should remove the GUI and all roles from the host except things related to Hyper-V and used in your environment like Failover Clustering and MPIO.
As a best practice, set a Windows 8.1 VM as your management station and install RSAT tools on it including Hyper-V Manager. It also comes with Powershell modules you need to run Powershell commands and scripts against all your hosts and VMs.
On the machines to be managed by Powershell you need to enable Powershell Remoting. In Server 2012 and above and Windows 8 and above this is enabled out of the box (even core versions). In older versions of Windows
enable Powershell Remoting manually as shown in this post.
On the management Win 8.1 VM that has RSAT installed, if the managed machines belong to the same domain as the managing station, you're good to go. If not, run this command on the managing station:
winrm s winrm/config/client "@{TrustedHosts=""My2003Server,host2,host3,vm4""}"
Execute your scripts against multiple machines by using Invoke-Command as in:
'Computer1','Computer2','Computer3' | % {
$Result = Invoke-Command -Computer $_ -ScriptBlock {
Get-Process
$Result
This example, will execute the commands in the scriptblock on each of the 3 computers in line1, and return the result.
For more information see
Don Jones' Secrets of Powershell Remoting eBook.
Sam Boutros, Senior Consultant, Software Logic, KOP, PA http://superwidgets.wordpress.com (Please take a moment to Vote as Helpful and/or Mark as Answer, where applicable) _________________________________________________________________________________
Powershell: Learn it before it's an emergency http://technet.microsoft.com/en-us/scriptcenter/powershell.aspx http://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx -
FTP - Run OS Command before file processing
Hi,
I have a requirement wherein I need to FTP a file from XI to a folder in a FTP server . Now FTP Server is set up in such a way that I cannot put the file directly. Before transferring the file , I have to use CD ( change directory command ) to access a particular folder and then transfer the file. This means that I cannot give the folder information directly to TARGET DIRECTORY.
To address this, I decided to use the feature "Run OS Command BEFORE file processing " . And wrote a command 'cd <foldername> .It is not working. Then I tried using "Run OS Command AFTER file processing " and it also didnot work.
Does anyone have any clue how can I address this requirement using FILE Adapter.
thanks,
rakeshHI,
OS commands will be executed in XI server not in the FTP server. So first you need to connect into FTP server and then you need execute CD command.
option 1) Get the absolute path ie direct path from FTP server so that you can directly connect to FTP server's specific directoty
22) In this case , write the file into your XI server itself by NFS File Transport protocol. Then ftp this file from your XI server into FTP server using Shell Script.
So write a shell script which will be executed in the XI server, inside this write a logic of tranfer of files with FTP protocol. This shell script is executed from the Reciever File adapter with the option OS command.
Hope this helps,
Regards,
Moorthy -
DVD player does not play - Error message "Create Overlay Failed
Can anyone please help. The player on my Equium does not playback any DVDs using either InterVideo WinDVD. Error message "Create Overlay Failed ... Please lower your screen resolution or screen depth." Any help appreciated. Thanks Owen
Horwath
Thanks for pointing me in the direction of VLC Player. I had no idea what VLC is but it seems a safe (and free) feature. I googled it and downloaded latest version for XP. All DVDs now play perfectly! Still no joy with other players but who cares. Many thanks, full marks. Owen
Maybe you are looking for
-
i have one array of string score1[] and i want to update those value in table how the query should be......... i thought it work as like for insert query but following is not working PreparedStatement ps = con.prepareStatement("update class_test_scor
-
My iphone 6 stopped receiving calls after upgrading to ios 8.2
I have a new iPhone 6, 64 GB. I tried upgrading it 2 days ago to iOS 8.2. The first time it froze for a long time and when it started, everything seemed to be ok until I opened my messages, the screen froze then my messages opened a blank page, then
-
Don't get me wrong fellow Apple gurus....but why am I always having issues utililizing Apple goods. It would be a PERFECT WORLD if the whole world was all about the fruit......BUT THEY'RE NOT. The iWeb 3.0.3 update DID fix alot of previous issues but
-
Dear SD Gurus. I want to copy know the seeting of copy control between. F2-----RE OR----RE I have tried once for BOM. Header Item Catagory TAP Item level TAN. When I am trying to copy its showing error. Plz let me know where I am making mistake. Rega
-
Needing help with syncing without erasing PLEASE!!
My computer had to be reset to factory settings. I re-downloaded itunes and attempted to sync my ipad but it says it will erase my ipad & replace with whats in the itunes since it is synced with another library. This is the same computer that it was