Hi,
I'd like to copy (or move) a worksheet from one workbook to another workbook with Powershell.
I had done this before and cant remember how. I think I used CopyTo() funtion.
Just to get started.
$missing = [System.Type]::missing
$excel = New-Object -Com Excel.Application
$wb1 = $excel.Workbooks.Add($missing)
$wb2 = $excel.Workboo...
Hi,
I'm trying to use PowerShell with web deployment based on this
article
This is how my script looks like
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Web.Deployment")
function Sync-Provider($provider, $sourceLocation, $destLocation)
{
$destBaseOptions = new-object Microsoft.Web.Deployment.DeploymentBaseO...
Hi all,
In short I have a volume that I need to assign a drive letter to (using diskpart). The problem now comes in that the volume does not remain the same. You enter disk part a do a "list volume" and the specific volume would be volume 0, then "exit". Enter again and the do a "list volume" again and this time it is volume 4. And so i...
I would like to use Get-WmiObject Win32_NetworkAdapterConfiguration to return the ip address of a network card. Unfortunately, I cannot figure out how to format the output to display only the IPv.4 address.
Get-WmiObject Win32_NetworkAdapterConfiguration | Select IPAddress | Where-Object {$_.IPaddress -like "192.168*"}
Displays:
IPA...
I am on a Windows 7 machine trying to execute a PowerShell script to copy a template directory to another directory. The command I am executing looks like:
Copy-Item -path "$projectsFolder$SourceFolder" -destination "$Test" -recurse -verbose;
The parameters are as follows:
path: C:\Users\username\Documents\Visual Studio 2010\Projects...
Synopsis:
I am trying to convert a shell script from UNIX to Powershell.
The script cannot "hardcode" the path, but must instead list a directory to dynamically build the path at runtime.
Also, the script must pass in 1 parameter to indicate the "type" of the run.
I am placing my "attempted" re-write of the script (after much googling/...
I am getting the same error described here:
http://forums.iis.net/p/1033115/1700749.aspx
I have a PowerShell cmdlet that tries to control our web application running on Windows Server 2008 SP2 and IIS 7. One of the first things it tries to do is try to connect to the remote machine using WMI. It does this using code like this:
Conne...
I'm trying to parse a file that contains blocks of text in this format(there can be 1-n of these):
-----------------------------------------------------------
KB Article Number(s): 2028769, 2072493, 2120979, 2143880, 2163958, 2163980, 980653, 980883, 981155, 981867, 982321, 982850
Language: All (Global)
Platform: x64
Location: (http://f...
Is it possible to split a Powershell command line over multiple lines? In Visual Basic I can use the underscore "_" to continue the command in the next line.
...
So I have a script that will go through and ping all the servers from a list that is stored in SQL Server. The script works fine but it does it all sequentially (lame).
Can someone help me out as to how I would change this to use multithreading instead of a foreach loop?
$Server = "ServerName"
$Database = "DatabaseName"
$con = ...
Note: I'm using ConvertTo-XML and cannot use Export-Clixml:
I create a simple PSObject:
$a = New-Object PSObject -Property @{
Name='New'
Server = $null
Database = $null
UserName = $null
Password = $null
}
I then convert it into XML using ConvertTo-XML:
$b = $a | Convertto-XML -NoTypeInformation
The XML looks li...
I am trying to optimise a login script to make it as robust and quick to execute as possible.
The script logs a number of drives, and I can see I can use either:
(New-Object -ComObject WScript.Network).MapNetworkDrive("X:", \\myserver\myshare))
or
net use x: \\myserver\myshare
To map the drives.
Which is the "better" way? The "tr...
Not sure what the eff' is wrong! I am using Powershell 2.0 on Windows 7. Had this same script working on Windows XP , am i just missing something?
$server = "server1-vm1.prod.ds.russell.com"
$name = "Superduper_Reports"
$iis = [ADSI]"IIS://$server/W3SVC/AppPools/$name"
$iis.psbase.invoke("recycle")
Error (that invoke looks okay to me...
I am trying to backup a drive from a laptop that is defunct. This drive was pulled from the machine and mounted in an external enclosure and connected to a desktop via USB.
Laptop that the drive was pulled from is Windows 7 Pro, and the desktop I connected the laptop drive to is Windows 7 Ultimate.
I am running PowerShell on the deskto...
I've read the whole thread about running PowerShell under .NET 4.0, including the warnings about what happens when using the registry keys to make the scripts run under that framework.
So far, I only get the desired result with the registry keys. Is anyone aware of a way to make this work without changing the registry keys? When I c...
Hi,
I trying to execute the powershell script in C#. But I am getting the exception like "Assignment statements are not allowed in restricted language mode or a Data section."
Here is my C# code :
string script = System.IO.File.ReadAllText(@"C:\script.ps1");
PowerShell exec_script = PowerShell.Create();
exec_script.RunspacePool =...
In a PowerShell script, I have some objects that I pass to the Format-Table CmdLet.
The output of my script looks like this:
Something...
Operation AttributeName AttributeValue
--------- ------------- --------------
Delete Member John Doe
Something else...
Since the meaning of the fields is pretty self-explanatory, I wo...
Using Powershell I can get the directories with the following command:
Get-ChildItem -Path $path -Include "obj" -Recurse | `
Where-Object { $_.PSIsContainer }
I would prefer to write a function so the command is more readable. eg:
Get-Directories -Path "Projects" -Include "obj" -Recurse
And the following function does exactly t...
I have a lot of log files that I wish to extract the distinct error message from for a specific trace writer.
The log files are SharePoint ULS logs.
The headings are:
Timestamp
Process
TID
Area
Category
EventID
Level
Message
Correlation
So given a specific process name I want all distinct Messages.
If I was to use SQL I would write ...
Scenario....
I am writing a powershell scrip to Automate some UI Testing, there are a bunch of things that I have to do re, checking code out of a repository, building, copying installers, then at the end I want to run TestComplete and test the installer UI...
The Installer runs in elevated mode as it writes to program files, registry ...