powershell_scripts | Miscellaneous PowerShell scripts | Command Line Interface library
kandi X-RAY | powershell_scripts Summary
kandi X-RAY | powershell_scripts Summary
Repository of useful(?) PowerShell scripts.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of powershell_scripts
powershell_scripts Key Features
powershell_scripts Examples and Code Snippets
Community Discussions
Trending Discussions on powershell_scripts
QUESTION
I am trying to use WinSCP to create a PowerShell script to automate an SFTP transfer. I am able to connect and do simple transfers, but I want to transfer yesterdays files only. For that I need a filemask which I can't get to work.
Below is my code. I am taking this script, putting it in Notepad++, saving it as a PowerShell script and running it. The SFTP connection part works as I have used this to grab all files on the SFTP. So I am sure its the file mask part.
...ANSWER
Answered 2020-Apr-29 at 05:59It's not the file mask. – You have a space after the backtick at the (seemingly) end of the lcd
line.
So the backtick escapes the space, and not the newline. Consequently, the get
line is interpreted as a new PowerShell code line.
It's basically a PowerShell equivalent of this common WinSCP problem with batch-file:
https://winscp.net/eng/docs/faq_batch_file#newline_escaping
Though in general, in PowerShell, you should use WinSCP .NET assembly.
QUESTION
PowerShell cmdlet Test-Path :c\df -IsValid
(and the variation Test-Path -IsValid :c\df
) is returning true
for syntax that is clearly not valid. Can someone shed light on this; am I missing something?
ANSWER
Answered 2020-Apr-16 at 23:57For the purpose of the example I provided, the following is a solution:
QUESTION
Greetings everyone and Happy New Year.
I just learned about PowerShell two days ago and it shows. I am trying to make custom Balloon tips and didn't what to make separate ps1 scripts for every possible event. What I needed was a ps1 with parameters.
I found this bit of code at this site: GitHub Invoke-BalloonTip
And I call successfully call it from the PS window with:
...ANSWER
Answered 2019-Jan-03 at 10:51I think the issue is with the original Invoke-BalloonTip.ps1
as it tries to use the System.Windows.Forms.ToolTipIcon
type before it is available (via loading System.Windows.Forms
). Adding it earlier in your command should fix things (though it does seem a bit hacky):
QUESTION
I have a Powershell script issuing the Move-Item command to move some 3D CAD directories and subdirectories from one network share to another. About 300 parent folders a day. I am having the most strange problem. All parent folders are copying to the destination just fine, but about 10 of the 300 objects are not being removed from the source. It seems that any subdirectory that contains a type of png scan file, will not remove from the source; it copies fine, just doesn't remove from source. No error is reported in the -verbose log output. The file sizes are not large, < 50MB each. Doing some testing, I also noticed that if I run the script once, the problem occurs, but if I run the script again with no changes, it moves the remaining objects that it did not move on the initial run. Another observation is that if I run the script where the source and destination are on the same share, the problem does not occur. The problem only occurs when source and destination are on different shares. Same problem using both versions 5.1 and 4.0.
I also tried using some simple png files I created myself just by saving a jpg screen print as a png, and those png files copy and remove fine. So something is special about these 3D CAD png files. I even tried copying off the parent folder to share to make sure no one or no program is locking the original files, and the problem still happens.
I have been successful at replacing the move-item command with a robocopy command, and it works perfectly, so I could use robocopy to solve my problem, but I want to figure out why the move-item command is having this problem. My only theory is that if on the same share, no data is actually being moved, only the reference to the file, ie pointer, ie FAT (file allocation table) is being changed. When crossing shares the actual file data has to be moved, so something is funny about these files that prevents that from happening. But as stated above, if I run the script a 2nd time, the remaining files copy and remove fine. So that leaves a little unexplained.
Just wondering if anyone has any ideas.
See the code samples below, and also some screen prints of the source folder structure before and after.
...ANSWER
Answered 2019-Oct-23 at 16:25You are using /R:3
parameter for robocopy
, meaning it retries to move the folder up to 3 times if an error is present.
I am not aware of such functionality in PowerShell, but you could easily write a small utility function for this.
Assumptions:
1) In the loop code, it checks if the source folder exists, if Yes, it continues up to $retries
times with Sleep
of 2 seconds.
QUESTION
I am trying to use Terraform's external provider to run a PowerShell script.
I am not able to pass parameters to the script from Terraform.
I am using the following code to run the script:
...ANSWER
Answered 2018-Nov-05 at 20:15A data source needs to output something which you don't currently appear to be doing. The external data source in particular needs JSON output on stdout
which could then be accessed under the result
attribute of the data source.
So to continue your example PowerShell script you might want something like this (untested):
QUESTION
I need to run a Powershell script to create AD user via a batch file. The thing is I need to run this PS script with elevated privileges (domain admin account). I have tried to script a '.bat' file which encloses all this information but I have been unsuccessful so far. Here is the script :
...ANSWER
Answered 2018-Feb-23 at 18:42you can start powershell with another credentials
QUESTION
Using wkhtmltopdf in Powershell, the PDF file is printing as expected, although it is throwing a warning as follows:
& "C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe" --print-media-type -q --header-left [webpage] --header-font-size 7 --footer-left [isodate] $listing.Url $pdfDest
ANSWER
Answered 2017-Jan-09 at 07:03I can see from the error that the command is referring to get_individual_aircraft.ps1
at line 138.
Could you please put
$ErrorActionPreference = 'SilentlyContinue';
in that script and see if it works. I believe that EXE is getting called with the help of that script.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install powershell_scripts
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page