powershell-ise

Windows Forms look different in Powershell and Powershell ISE. Why?

心不动则不痛 提交于 2019-11-30 18:16:20
I have written a script which is basically a small wysiwyg signature generator for Outlook. We want our signatures to be in corporate colours, and semi-standardised - hence the requirement for this. I did the development work in Powershell ISE and all looked good. However, when I run the script just using powershell (as the users will) it looks totally different: Powershell vs Powershell ISE http://www.freeimagehosting.net/uploads/1d6e6c5c6f.png The top one was generated in ISE, and looks as I want it. The bottom one was run from powershell directly and seems to have visually regressed five

Get relative path of files in sub-folders from the current directory

非 Y 不嫁゛ 提交于 2019-11-30 16:47:12
Is there any straight-forward way (by use of cmdlets or .NET classes) to obtain only the relative path of a file in a sub-folder from a given path? eg current folder is C:\MyScript and there is a sub-folder called Data with a file Test.txt , so I would like to see Data\Test.txt instead of C:\MyScript\Data\Test.txt The Resolve-Path cmdlet has a -Relative parameter that will return a path relative to the current directory: Set-Location C:\MyScript $relativePath = Get-Item Data\Test.txt | Resolve-Path -Relative 来源: https://stackoverflow.com/questions/10972589/get-relative-path-of-files-in-sub

Get relative path of files in sub-folders from the current directory

梦想的初衷 提交于 2019-11-30 16:21:46
问题 Is there any straight-forward way (by use of cmdlets or .NET classes) to obtain only the relative path of a file in a sub-folder from a given path? eg current folder is C:\MyScript and there is a sub-folder called Data with a file Test.txt , so I would like to see Data\Test.txt instead of C:\MyScript\Data\Test.txt 回答1: The Resolve-Path cmdlet has a -Relative parameter that will return a path relative to the current directory: Set-Location C:\MyScript $relativePath = Get-Item Data\Test.txt |

Is it possible to reset the runspace in Powershell ISE?

白昼怎懂夜的黑 提交于 2019-11-30 08:04:22
One of the features of PowerGUI is the ability to reset the Powershell Runspace as demonstrated in this article and this article . Is it possible to do this in PowerShell ISE? x0n I wrote a module called "ISE Session Tools" to do this a few months back. Essentially the runspace in ISE is equated to a "Tab" container, of which its child documents share the runspace. My script looks at the current open files, remembers them, creates a new Tab (runspace) and closes the old one, then adds the files you had open to the new Tab. Other features: AutoSaving of current session (files open in current

Windows Forms look different in Powershell and Powershell ISE. Why?

丶灬走出姿态 提交于 2019-11-30 02:33:53
问题 I have written a script which is basically a small wysiwyg signature generator for Outlook. We want our signatures to be in corporate colours, and semi-standardised - hence the requirement for this. I did the development work in Powershell ISE and all looked good. However, when I run the script just using powershell (as the users will) it looks totally different: Powershell vs Powershell ISE http://www.freeimagehosting.net/uploads/1d6e6c5c6f.png The top one was generated in ISE, and looks as

Is it possible to reset the runspace in Powershell ISE?

耗尽温柔 提交于 2019-11-29 10:58:41
问题 One of the features of PowerGUI is the ability to reset the Powershell Runspace as demonstrated in this article and this article. Is it possible to do this in PowerShell ISE? 回答1: I wrote a module called "ISE Session Tools" to do this a few months back. Essentially the runspace in ISE is equated to a "Tab" container, of which its child documents share the runspace. My script looks at the current open files, remembers them, creates a new Tab (runspace) and closes the old one, then adds the

How to copy a file to multiple folders in PowerShell

蹲街弑〆低调 提交于 2019-11-29 10:40:06
I am running a script that has multiple environments in it that can be selected from a window that pops up. the only problem I have run into is when I want to set up the script to copy from a source function that I have created and put it into multiple locations at once. The part of the code I need help with is posted below. $Source = Select-Boss $destination = 'D:\parts','D:\labor','D:\time','D:\money' "Calling Copy-Item with parameters source: '$source', destination: '$destination'." Copy-Item -Path $source -Destination $destination The section below is how the rest of the copy functions are

Passing a variable to a powershell script via command line

我只是一个虾纸丫 提交于 2019-11-28 04:50:19
I am new to powershell, and trying to teach myself the basics. I need to write a ps script to parse a file, which has not been too difficult. Now I want to change it to pass a variable to the script. that variable will be the parsing string. Now, the variable will always be 1 word, and not a set of words or multiple words. This seems uber simple yet is posing a problem for me. Here is my simple code: $a = Read-Host Write-Host $a When I run the script from my command line the variable passing doesn't work: .\test.ps1 hello .\test.ps1 "hello" .\test.ps1 -a "hello" .\test.ps1 -a hello .\test.ps1

How to copy a file to multiple folders in PowerShell

浪子不回头ぞ 提交于 2019-11-28 04:04:26
问题 I am running a script that has multiple environments in it that can be selected from a window that pops up. the only problem I have run into is when I want to set up the script to copy from a source function that I have created and put it into multiple locations at once. The part of the code I need help with is posted below. $Source = Select-Boss $destination = 'D:\parts','D:\labor','D:\time','D:\money' "Calling Copy-Item with parameters source: '$source', destination: '$destination'." Copy

Create directory if it does not exist

倾然丶 夕夏残阳落幕 提交于 2019-11-28 03:07:10
I am writing a PowerShell script to create several directories if they do not exist. The filesystem looks similar to this D:\ D:\TopDirec\SubDirec\Project1\Revision1\Reports\ D:\TopDirec\SubDirec\Project2\Revision1\ D:\TopDirec\SubDirec\Project3\Revision1\ Each project folder has multiple revisions. Each revision folder needs a Reports folder. Some of the "revisions" folders already contain a Reports folder; however, most do not. I need to write a script that runs daily to create these folders for each directory. I am able to write the script to create a folder, but creating several folders is