Tagged Questions
-2
votes
0answers
27 views
Fail the robot agent job if the batch file failes
I have built the batch file that will copy the file from source to destination server. I do compare the file size on both source and destination and provide the error message which is logged into ...
3
votes
1answer
73 views
How to transmit a secure password over SSH using PowerShell?
I'm writing PowerShell modules that execute commands or scripts over SSH on remote Windows machines, and I'm looking for a way to transmit a password (or other sensitive information) over the ...
-1
votes
1answer
46 views
Error while giving Powershell access to Target System from Source machine
I am basically a C# guy but my requirement is to give Powershell access to the remote/target systems (Say Client) from my system (Say Server). I am part of the administrator group in those remote/...
0
votes
1answer
30 views
Test UNC paths from a text list and write each line with its result
I have a text file with several DFS shares that looks as follows:
\\\computer1\dfsshare1
\\\computer2\dfsshare2
\\\computer3\dfsshare3
\\\computer4\dfsshare4
\\\computer5\dfsshare5
I want ...
0
votes
2answers
56 views
Filter a file content to exclude all the lines with matching strings from another file in PowerShell
I need to filter the content of a variable to exclude all the lines with matching strings from a SubnetExceptions.txt file as filter, just as a grep -v command.
The $Valuevariable suffered lots of ...
2
votes
1answer
91 views
Basic Powershell Logging
I have written an automation script in Powershell that runs a small number of functions many times...
I am beginning to get my head around Powershell, but I still do pleeeenty of stupid stuff... I ...
-1
votes
1answer
24 views
Trigger an email alert in PowerShell when ExpiryInDays data returned by PSCustomObject is less than or equal to 30
I have a script here that will return the information I need from the certificates binded in IIS from different web servers.
$Date = Get-Date
$servers = Get-Content C:\servers.txt
$cert = Foreach (...
0
votes
0answers
97 views
Passing strings with spaces to PowerShell
Ultimately, I want to be able to call my PS script from VBA (Excel), but the easiest way to do that seems to be with system batch commands - so I'm testing my script with a BAT file.
The script ...
1
vote
2answers
127 views
Is it secure to use a password argument in a Windows command?
Imagine that we have a program or script that can take a password (or other sensitive information) argument:
> program.exe /password:secret
For Linux, best practice generally recommends against ...
0
votes
0answers
86 views
Getting Error “The system cannot find the file specified” in one session but not another
Below is my script:- Git is installed successfully and running fine and git-tfs also working fine but still getting "The system cannot find the file specified". but Once I run my script in ...
0
votes
2answers
56 views
Powershell script to find currently bound expiring certificates in IIS remotely
I'm currently working on a script that will send an email once the certificates binded in my web servers' IIS are nearing there expiration date. I do have the script to send it in email. All I need to ...
0
votes
0answers
104 views
What are the differences between script blocks, subexpressions, and subshells?
On the surface, these constructs seem similar in PowerShell:
{} Script Block - from about_Script_Blocks:
In the Windows PowerShell programming language, a script block is a collection of ...
0
votes
1answer
25 views
Visual Studio Build Agent scripted setup
I´m trying to automate VSTS Build Agent Setup (https://www.visualstudio.com/en-us/docs/build/actions/agents/v2-windows).
However there's an interactive step in the process. It´s a cmd script file ...
1
vote
0answers
106 views
How to check if an ad user is logged for the his first time
I have a PowerShell script, configured to run in logon GPO. In my script I need to check if the current user is connectiong for the first time or not.
I tried to test if the user profile folder exists ...
0
votes
1answer
35 views
check if DSQuery was successful in PowerShell?
I'm trying to convert a batch script to PowerShell. I encountered this piece of code, can anyone tell me how to convert this to PowerShell?
dsquery ou -domain "$SysDomain" -name "$FuncOU,$DestOU" || (...
1
vote
1answer
30 views
Passing optional parameters to subroutines without instantiating them
I have a script that prompts the user for input (web address, username and password, etc.) and validates those inputs or prompts the user again.
Now I want to be able to call this script while also ...
4
votes
2answers
4k views
How to compare if a folder exists and if it does not exist, create her
I have the following problem, I need to create a script that compares if the directory exists and if it does not exist, create it. In the linux shell, I use the parameter -F to check if the directory ...
0
votes
2answers
297 views
Create a startup script from Powershell on windows
I'm working on an installation script of certain software I am developing. Installation of the software on a remote server requires a certain startup script to run on each boot.
I'm writing a ...
0
votes
2answers
743 views
Copy-Item for copy files from local to remove server using credentials
I am trying to copy some files and folder from my local machine to a remote server:
Copy-Item .\copy_test.txt -destination "\\serverip\c$\backups\"
but I'm getting an error:
Copy-Item : Logon ...
0
votes
1answer
283 views
PS VM script: error validating argument for Add-VMNetworkAdapter from CSV file
So, I recently started teaching myself about PowerShell scripting since the reading I did and the videos I've seen show that it's way easier to do almost, if not, everything in PowerShell compared to ...
0
votes
0answers
371 views
unattend setup returns error 0xfffd0000 during specialize pass
I'm trying to run a PowerShell script using unattend.xml file for Windows Server 2012 R2 setup. I specified that PowerShell file to execute at specialise pass stage. Please check the below unattended ...
1
vote
1answer
697 views
#!/bin/bash equivalent in windows / specify interpreter for executable script IN the script
I don't really know which part of the described technology stack the behaviour i'm describing is actually a property of - linux, or bash/sh? but it does not really matter i guess.
Anyway, on linux, ...
0
votes
0answers
191 views
Windows Script to Daily Update of Folders/Files
Windows Box Script Creation:
I'm trying to create a script on a windows box that will be used to daily via task scheduler. The script would be a shortcut created by a script at midnight each night ...
0
votes
1answer
44 views
Powershell function not executing as expected
I have the following function that shows if any of the words in an array are contained in a string:
function AnyOf ([string] $line, [string[]] $list)
{
Write-Output "AnyOf!"
foreach($item in $...
1
vote
1answer
281 views
Powershell write to vbscript console(cscript.exe)
I have a requirement of running powershell script in silent mode through vbscript(cscript.exe).
Basic steps for script are as follow.
vbscript
WScript.StdOut.WriteLine "Welcome..."
WScript.StdOut....
0
votes
0answers
102 views
Windows powershell continuously write file a to file b
Hello powershell scripters,
i really can't get this one...
I have fileA.log which will be filled continuously with data.
Now i want to stream this file to a file B in another folder.
On Linux its ...
1
vote
2answers
126 views
WMI Scripting Windows 8 error
I have a problem with WMI in a machine with a Windows 8 Home Edition. I need to catch the CPU usage and the ProcessID by process. I've tried so many ways:
ShellExecute in Delphi
A *.bat with the code
...
1
vote
0answers
25 views
Contrasting results between bulk file rename utility and windows script
So I was using this command cmd /c dir /s /b |? {$_.length -gt 260} to find out a list of paths that exceed Windows limit of 260 characters. And this gave me 4 files when pointed to a folder. Then I ...
3
votes
1answer
1k views
Get all parameters passed to a function in PowerShell
I have a function as following. It generates a string as per the parameters passed.
function createSentenceAccordingly {
Param([Parameter(mandatory = $false)] [String] $name,
[Parameter(...
0
votes
1answer
60 views
Create windows script to traverse all subfolders of some folder, and delete a certain folder and all of it's contents if it exists
here's the trick. Supposing I want to free up some space, and run that script in F:\UnrealProjects, which has a bit over 50-60 subfolders, I would like that script to traverse all of it's subfolders, ...
0
votes
2answers
914 views
How to run internal Powershell script function from cmd.exe with arguments
I want to use a powershell (.ps1) script in the command prompt without using this commands
Powershell.exe -noexit Set-ExecutionPolicy Unrestricted -file "C:\Get-NetworkStatistics.ps1"
Currently ...
2
votes
4answers
2k views
Using the Explorer context menu to copy a modified version of the file path to the clipboard
The requirement I've got is pretty straightforward, but I'm struggling sifting through the huge amounts of unrelated information on the subject.
Requirement
I have files synchronised between my PC ...
2
votes
2answers
1k views
Using powershell and svn to delete unversioned files
I'm trying to write a build script to checkout code using Powershell. I need to be able to replace any modifications which were made to the working copy with the appropriate changes from the SVN repo. ...
26
votes
3answers
30k views
How to capture the Return Value of a ScriptBlock invoked with Powershell's Invoke-Command
My question is very similar to this one, except I'm trying to capture the return code of a ScriptBlock using Invoke-Command (so I can't use the -FilePath option). Here's my code:
Invoke-Command -...
0
votes
2answers
898 views
How to replace multiple values in a CSV or html file with PowerShell?
I wrote a script to read a list of folder objects into an xml file showing the properties for the folder. It also creates another xml file at a later point in time. After the delta xml file is ...
14
votes
2answers
8k views
When to choose development of a PowerShell Module over PowerShell Script
I am about to write a PowerShell Script for Windows administrators, in order to help them in certain tasks related to deployment of a web application.
Is there any reason I should favor or exclude ...