Tags down

Home » powershell


checking parameter passed is string and integer
should help you out Firstly, when you take input from screen using read-host the input will be read and stored as a string, irrespective of what you enter. You can confirm this by running the following command and entering a number:($checkInt = read-
TAG :powershell
Date : September 23 2020, 12:00 PM , By : Seagull
Can a string with a noteproperty be modified
Hope this helps The NoteProperty instance is associated with the specific object (string) instance you're piping to Add-Member.By assigning a different string instance to variable $t ($t = 'else'), the original instance is lost, and along with it the
TAG :powershell
Date : September 23 2020, 01:00 AM , By : Miller Chen
Calling script from resource folder in Jenkins shared folder
it should still fix some issue You can use libraryResource(file-in-resources) (docs) to load a file from the library resources as a text. That you can write to your workspace with writeFile (docs) and execute.As the library is checked out somewhere n
TAG :powershell
Date : September 23 2020, 12:00 AM , By : kizo
Open .exe on remote computer with Power Shell
seems to work fine If PowerShell remoting has not been enabled, and you are not an admin on the remote host, you cannot use Invoke-Command.As noted, you have not given a computername, so this would never work anyway.
TAG :powershell
Date : September 22 2020, 11:00 PM , By : Antti
How do I remove periods from file names using PowerShell?
may help you . One thing about string replacing: When I tried your example without escaping the period, it didn't replace anything and returned nothing (empty string), which I believe answers your "Cannot bind argument to parameter 'NewName' because
TAG :powershell
Date : September 22 2020, 08:00 PM , By : Thaer Abu AlQais
PowerShell steps to fix slow startup
Hope this helps When PowerShell starts to become slow at startup, an update of the .NET framework might be the cause. To speed up again, use ngen.exe on PowerShell's assemblies. It generate native images for an assembly and its dependencies and insta
TAG :powershell
Date : September 22 2020, 05:00 PM , By : Tiago Mortágua
Terraform GCP unable to run metadata command for windows instance to create a user
With these it helps In your example, there is a typo adminstrators, it should be administrators.Solution
TAG :powershell
Date : September 22 2020, 05:00 PM , By : Kenza Maana Marjani
PowerShell - Want to create fixed width output file for data retrieved from DB using invoke-sqlcmd
like below fixes the issue this uses the -f string format operator and the ability to assign column sizes left/right alignment. a negative alignment means to align LEFT instead of the default align-right. i don't have your SQL stuff handy, so i used
TAG :powershell
Date : September 22 2020, 11:00 AM , By : Erik Carlsson
Uisng test-json on an array of json files
fixed the issue. Will look into that further The problem is in using Test-Json.Based on your code-snippet it seems that, You are assuming that it will throw error if JSON is not in correct format which is not the case.The error generated by Test-Json
TAG :powershell
Date : September 22 2020, 06:00 AM , By : Hawon Nguyen
Jenkins Pipeline Script - evaluate stdout of batch/powershell
hope this fix your issue If you are trying to evaluate the exit code of a command, then the easiest path for this is to utilize the returnStatus argument of the bat method. This will return the status value of the command as an integer type. You can
TAG :powershell
Date : September 22 2020, 03:00 AM , By : nadjib
Get all files in a folder and in a specific subfolder in PowerShell
I think the issue was by ths following , I got the following folder structure for the output of my programm: , You could do this using
TAG :powershell
Date : September 22 2020, 02:00 AM , By : Dalim Mohammad
Get XML node children using a variable
this one helps. Given the following file: , I had done a couple things wrong. This functions as desired:
TAG :powershell
Date : September 21 2020, 09:00 PM , By : R.Thomas
Is there a powershell command that would power on another host?
Hope this helps If you use powershell 5.0 + , you can use the Restart-Computer cmdlet.
TAG :powershell
Date : September 21 2020, 07:00 PM , By : Roger Deran
How do I change the value of a variable using a function in powershell?
wish help you to fix your issue Without fiddling around with scopes or sending variables by reference, why don't you simply have the function return 'Fail' or 'Success'?BTW The .Count property is of type Int32, so you should not surround the value 0
TAG :powershell
Date : September 21 2020, 01:00 PM , By : shits facer
How do I get the SID number from whoami /all in Powershell?
may help you . The problem with whoamiis that it is simply returning an array of lines which you then have to analyze yourself. Are you bound to use whoami? There are more convenient ways to find your SID. For example:
TAG :powershell
Date : September 21 2020, 10:00 AM , By : Ssnb
Get HyperV Memory Size without Elevation
around this issue Option 1Did you try Exporting the configuration of a virtual machine and then read the required parameters from it? That might be helpful for you.
TAG :powershell
Date : September 21 2020, 03:00 AM , By : V . Sruthy
Get the global memory maximum available for Docker in windows, within powershell
it should still fix some issue I would like to write a script that checks that Docker has access to a minimum X amount of memory, on Windows. I need this to work with Docker running on Hyper-V. , Of course as soon as I asked this I found it.
TAG :powershell
Date : September 21 2020, 03:00 AM , By : artbrew
Catching errors in powershell workflow
To fix this issue Exceptions are only thrown/caught when terminating errors are thrown, which are only thrown by cmdlets, .NET libraries, or native code when P/Invoke is in play. In order to handle failures with external commands, such as checking wh
TAG :powershell
Date : September 20 2020, 07:00 PM , By : Oussama Baybay
Powershell command to delete everything that starts with _
will be helpful for those in need You should use Get-CimInstance instead of Get-WmiObject. If you read the help for Select-Object you will learn that you can include desired properties and you can exclude properties if you like:
TAG :powershell
Date : September 20 2020, 04:00 PM , By : Alexander Juda
powershell - gci exclude directories and subdirectories where parent folder contains TECH?
this will help name isn't fullname. -contains doesn't do what you think, it matches whole words in an array basically, and doesn't use wildcards.
TAG :powershell
Date : September 19 2020, 05:00 PM , By : DzDevTeam
How do I print file for a specific parent/child using Get-ChildItem?
it helps some times you are printing the $subDir - in the 1st case that is directory1-uat. then you are getting the file list of the parent directory of $subDir. you want the files in $subDir, not in the entire parent tree. [grin] try replacing $subD
TAG :powershell
Date : September 19 2020, 04:00 PM , By : Janek Vogel
Powershell rename files add brackets
I hope this helps . You can do the following assuming you are currently in the directory that contains the files:
TAG :powershell
Date : September 19 2020, 05:00 AM , By : Kurmo Rootsi
Check if a variable is a string list/array?
this one helps. You can use the -is operator to check the type to check if it's an array:
TAG :powershell
Date : September 18 2020, 05:00 AM , By : rohit
Using dot source function in params
around this issue It would be beneficial to instead turn that script into a PowerShell Module, despite your statement that you desire to avoid one. This way, your functions are always available for use as long as the module is installed. Also, despit
TAG :powershell
Date : September 16 2020, 04:00 AM , By : codemonkey
How to combine PowerShell runspace stderr, stdout etc into a single stream
I hope this helps . To access output from all streams in output order when using the PowerShell SDK, you'll have to resort to *>1 as well:
TAG :powershell
Date : September 16 2020, 01:00 AM , By : Ryan Chad
Replace a character in all txt files
With these it helps I'm looking to replace the character 'a' with 'o' in all txt files in a directory: "D:\Aither\Pca\Stat\" , Try this:
TAG :powershell
Date : September 11 2020, 04:00 PM , By : Raj Roy
Powershell search CSV file with no headers and non-standard delimeter; return only certain columns in results
I hope this helps you . since i am too lazy to provide the data you didn't provide, i will skip reading the data in. you can use Get-Content for that. [grin] what this does is ...
TAG :powershell
Date : September 11 2020, 02:00 AM , By : yoga nanda
PowerShell script to configure Windows service with no password user
Hope this helps I would like to configure a service (adding log in user and set the start up to automatic) and start it using a Powershell script: , Bit easier - use WMI.
TAG :powershell
Date : September 04 2020, 01:00 PM , By : jodk
Powershell script errors first time but works on second attempt
I wish did fix the issue. I have a powershell script that searches for xls files and converts them to xlsx. Every time I run it for the first time I will get the error , Start the script with the line
TAG :powershell
Date : September 01 2020, 09:00 AM , By : swrao
provide password while unzipping a .zip file
I wish did fix the issue. As per the built-in help files and the online PowerShell documentation, the Expand-Archive cmdlet provides no means for this use case, nor does it have an option to add a password.All cmdlets that do provide such a mechanism
TAG :powershell
Date : August 29 2020, 05:00 AM , By : Erik Lincoln
How to Create Function Parameters that do not require input Powershell
wish help you to fix your issue You're looking for a SwitchParameter! There's a nifty [switch] type accelerator for it, so you can implement your own such parameter like this:
TAG :powershell
Date : August 25 2020, 01:00 PM , By : srikanth vemaraju
Powershell: Check computer to see if reboot is required otherwise skip
this one helps. I'm assuming you are using this code found at https://ilovepowershell.com/2015/09/10/how-to-check-if-a-server-needs-a-reboot/
TAG :powershell
Date : August 24 2020, 10:00 PM , By : Abhi
powershell : find subdirectories with the longest paths
I wish this help you I would like to find the longest paths among the subdirectories in a given directory, because I ran into this error: , This returns the 5 directories with the longest paths:
TAG :powershell
Date : August 22 2020, 06:00 PM , By : vahid vahedi
How to have multiple values for one key in hashtable from csv
Does that help If you want a hashtable, then the easiest way would be to make an empty one, import your CSV, group things by ID, then add each group to the hashtable.
TAG :powershell
Date : August 20 2020, 12:56 PM , By : Bayader
Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk