powershell-3.0

powershell : i cant open remote session without specify the FQDN anymore

泪湿孤枕 提交于 2019-12-02 22:13:39
问题 Some days ago, i was able do create a remote session using short name of the remote server/workstation. This doesnt work anymore error is : + CategoryInfo : InvalidArgument : (computername1:String) [Enter-PSSession], PSRemotingTransportExcepti + FullyQualifiedErrorId : CreateRemoteRunspaceFailed but when i use the complete domain name it is working : nsn computername1.domain.com Dns resolution is correct, what else can i check to troubleshoot this problem ? 回答1: I've finaly found it ! :) I

PowerShell comparison operators

只愿长相守 提交于 2019-12-02 20:44:16
问题 PowerShell has a unique set of comparison operators: -eq -gt -lt -ne etc. I vaguely remember using such operators in a different language, but can't recollect which one. Which other languages use such notations? what is reason for not using the standard operators (==, >,<, !=)? 回答1: The Unix test command for instance uses similar operators. Perl has operators like that too, although without the leading hyphen. The reason for PowerShell to use mnemnics rather than symbols for the comparison

Powershell get ipv4 address into a variable

天涯浪子 提交于 2019-12-02 18:57:46
Is there an easy way in powershell 3.0 Windows 7 to get the local computer's ipv4 address into a variable? Lucas Here is another solution: $env:HostIP = ( Get-NetIPConfiguration | Where-Object { $_.IPv4DefaultGateway -ne $null -and $_.NetAdapter.Status -ne "Disconnected" } ).IPv4Address.IPAddress Jana Sattainathan How about this? (not my real IP Address!) PS C:\> $ipV4 = Test-Connection -ComputerName (hostname) -Count 1 | Select IPV4Address PS C:\> $ipV4 IPV4Address ----------- 192.0.2.0 Note that using localhost would just return and IP of 127.0.0.1 PS C:\> $ipV4 = Test-Connection

Example showing how to override TabExpansion2 in Windows PowerShell 3.0

落爺英雄遲暮 提交于 2019-12-02 17:41:29
Does anyone have an example showing how to override the TabExpansion2 function in Windows PowerShell 3.0? I know how to override the old TabExpansion function, but I want to provide a list of items for the intellisense in PowerShell ISE. I looked at the definition of TabExpansion2 and it wasn't easily understandable how I inject my own code in the the tab expansion process. Charlie I think this example should give you a good starting point: Windows Powershell Cookbook: Sample implementation of TabExpansion2 . The example code shows that you can add code both before and after the default calls

TFSSecurity to change git branch permissions

£可爱£侵袭症+ 提交于 2019-12-02 17:18:10
问题 I am implementing the TFS Security commands to change a git master branch acess control permissions to DENY for contribute field. Below is the command I am using: /tfssecurity.exe /a+ GitRepositories repositories/[543473b8-6186-42b3-bdab-b22bc44cc8f8/] GenericContribute n:'"[Projectname]\TFSGroup'" DENY /collection:CollectionURL" I am using powershell 3.0 for this project and I get below error Error: The security namespace GitRepositories does not exist. Could someone help me with this? 回答1:

Powershell Script to count .txt files only in a directory

孤者浪人 提交于 2019-12-02 16:47:49
问题 My goal is to send email to some users to notify about the current count of the files inside some folder directories. I need to count files only with .txt extensions and exclude folders and files inside this. please see below illustration U:\TESTING\Main Folder U:\TESTING\Main Folder\Sub Folder 1 U:\TESTING\Main Folder\Sub Folder 2 output result should look somehting like this Main Folder row should be 1 only, but it also includes the sub folders 1 and 2 and the txt files inside those. Here's

Export function

假装没事ソ 提交于 2019-12-02 15:56:15
问题 I am trying to create a function in which a user has to give a filename that can not containt an empty string. Besides that, the string can not contain a dot. When I run this function, I keep looping when I enter "test" for example. Any idea as to why? function Export-Output { do { $exportInvoke = Read-Host "Do you want to export this output to a new .txt file? [Y/N]" } until ($exportInvoke -eq "Y" -or "N") if ($exportInvoke -eq "Y") { do { $script:newLog = Read-Host "Please enter a filename!

Mouse event don't work after first timer Tick

▼魔方 西西 提交于 2019-12-02 13:40:30
I'm using powershell to develop a little tool with graphic interface and I'm going crazy with this issue... For example: I have a label on a form that display "real-time" status of a ping. In the same time, if you click on the label, a popup message is displayed. function GoogleStatus ($Label) { $Google = "www.google.com" If (Test-Connection -ComputerName $Google -Count 1 -Quiet) {Label.Text = "Yes"} else {Label.Text = "No"} } function HelloMsg { [System.Windows.Forms.MessageBox]::Show("Hello","Funny Window",0,32) } [void] [Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")

How to queue another TFS (2012) Build from a TFS Build AND pass process parameters?

丶灬走出姿态 提交于 2019-12-02 13:26:37
问题 The product I work on comprises 3/4 seperate (non-dependant) TFS builds. I would like to create a single TFS build which queues the other 3/4 builds from within the ProcessTemplate AND, critically, pass process parameters to them. This build would wait for them all to complete and return an overall success/failure of the build. So my questions are: Can this be achieved by any existing 'standard' Workflow activities (my manager has had bad experiences with custom workflow activities)? If not,

Parsing a text file in PowerShell

↘锁芯ラ 提交于 2019-12-02 13:17:31
I have a text file with multiple users (in the exact format): username:t-Hancock phoneNumber: 555555555 username:a-smith PhoneNumber: 987654321 username:r-Byer phonenumber: 123456789 I am trying to get all these users into an object with two properties (name and phone number). I tried Get-Content , tried some regex from other posts, but I couldn't modify them because I didn't understand it. How could this be done? Graham Gold It's not that clear entirely what you want here - what kind of object and for what purpose? I'll go with an example of what you could do... Say you want to convert that