I want my powershell script to print something like this:
Enabling feature XYZ......Done
The script looks something like this:
Write-Output "Enabling feature XYZ......."
Enable-SPFeature...
Write-Output "Done"
But Write-Output always prints a new-line at the end so my output isn't on one line. Is there a way do do this?
...
Probably a simple question, but my brain isn't working today.
I am writing a small powershell script to do various tasks. These tasks are logically grouped into tabs, using a WPF TabControl.
A couple of the tabs do some checks to compare local file dates with server file dates, which takes a bit of time. (Only a few seconds, admittedly...
Hi,
I am unable to run remote installation of windows component on a remote server using sysocmgr.exe. It is working with "psexec.exe \ServerName -i sysocmgr.exe /i:%wnidir%\inf\sysoc.inf /u:\path\to\components.txt but I want to achieve the same results using powershell remoting.
I have powershell remoting with WinRM working fine, but...
I have a powershell script I want to be able to define different starting points for. Once the starting point is hit the script would pick up from that point and continue through the remaining code in the script. I don't believe that a case statement will work since I don't think that will just let the script flow through from whateve...
I'm using the following PowerShell 2.0 code to grab input from a vb inputbox:
[void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic')
$name = [Microsoft.VisualBasic.Interaction]::InputBox("What is your name?", "Name", "bob")
Sometimes when I run it the input box appears behind the active window. Is there a way...
I have written a script that inserts some test data into a document library. I intend to use it as a post-deployment step in Visual Studio 2010, so that the library is not empty after a retract & deploy.
The relevant portions of the script are:
Install.ps1:
$scriptDirectory = Split-Path -Path $script:MyInvocation.MyCommand.Path -Paren...
Hi,
I am attempting to move most of my daily working life to a terminal shell. I am a .NET dev so I run on WinXP purely for visual studio (just wait until I get better at emacs). I would really much like it if I could use an email client within a terminal (either using Console or powershell within Console).
From my uni days I know of ...
I have a script that I am utilizing functions to wrap parts of the code that allow me to move through the sections at a specified point. What I have found is that I have to have the functions listed first in the script for it to run correctly. Example:
$stepChoice = read-host 'Where would you like to start.'
switch($stepChoice)
{
...
I have a Powershell script that is going to be run through an automation tool against multiple servers. It works fine on Windows machines, as the remote calls use the tool's service account without any need for prompting or exposing any credentials in code. This script also runs against Linux machines via SSH using the SharpSSH package. ...
I have a Powershell script that needs to run under multiple hosts (PowerGUI, Powershell ISE, etc...) but am having an issue where sometimes a cmdlet doesn't exist under one of the hosts. Is there a way to check to see if a cmdlet exists so that I can wrap the code in an if block and do something else when it does not exist?
I know I co...
I am trying to write a Powershell script to run a general SQL command against a database. The idea is that Run-SQL "select ..." will run the SQL text against the currently open database. If the SQL statement is a query, it should return a DataTable. If it is a non-query (DDL or DML) it should return nothing ($null).
In order to do this,...
Is it possible to define an array of filenames (all files in different folders) and then in a loop delete them all, or do something else?
Actually I need to create a few symbolic links using mklink to one file, putting those links in a different folders, replacing the old links if there was any.
...
I've been working on some PowerShell functions to manage objects implemented in an assembly we have created. One of the classes I have been working with implements IEnumerable. Unfortunatly, this causes PowerShell to unroll the object at every opportunity. (I can't change the fact that the class implements IEnumerable.)
I've worked a...
I have this C# code to enumerate controls of a Form instance:
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = "";
Form2 form2 = new Form2();
foreach (Control control in form2.Controls)
{
PropertyDescriptorCollection properties =
TypeDescriptor.GetProperties(control);
...
I have defined an XML string using
$str = "<a><b></b></a>"
Now I want to load it into a [xml] variable to be able to manipulate it's nodes etc.
The row below results in an error...
$str = [xml]"<a><b></b></a>"
How do I do this?
...
I have a string
$string = "Active Directory"
and I want to make another string
Active_Directory_Results.txt
I would like to just do
$otherstring = "$string.Replace(" ","_")_Results.txt"
but that doesn't work out. What would be the correct way to pull this off?
...
One of my coworkers just came to me with an interesting problem.
He's displaying a WinForms form from a PowerShell script, and while the form opens successfully it does not get focus. Instead the PowerShell command window retains focus until the form is explicitly clicked.
The script is being run from the PowerShell command line using ...
I am in the process of writing a script to make changes to folder permissions. Before it does that I would to do some checking to make sure that I am working in the correct directory. My problem is how do I check to see if four subfolders (i.e. Admin, Workspace, Com, & Data) exists before the script progresses. I assume I would be using ...
I'm trying to run a simple job process in powershell 2.0 and it doesn't seem to run.
$job = Start-Job { Return "Some string." }
When I call $job, the status says it's running. But the problem is that it never completes.
Tried the same thing on my Windows 7 machine and it completes immediately.
I'm running powershell 2.0 on wind...
Can you overload functions in powershell ?
What I want to do is that my functin could accept string, array or some switch.
Example what I want:
Backup-UsersData singleUser
Backup-UsersData @('Alice', 'Bob',
'Joe')
Backup-UsersData -all
Best regards.
...