UnknownError when signing powershell script via Set-AuthenticodeSignature
I have obtained a code signing cert from our trusted CA. I am trying to sign a script in PowerShell ISE but getting "UnknownError." I have tried encoding the script as UTF-8, but I'm still getting the...
View ArticleHow to get Powershell Invoke-Restmethod to return body of http 500 code response
Invoke-RestMethod call returns only very unhelpful exception below and does not (as far as I can tell) allow you to collect the body content (JSON object shown in fiddler trace results). This seems a...
View ArticleCreate subdirectories using PowerShell
I have a CSV file that includes custoomers informations, from it I'm able to create folders for each customers using the below script :$Names = Import-Csv -Path “$PSScriptRoot\Info.csv” | Select-Object...
View ArticleHide progress of Invoke-WebRequest
How can I hide the progress display of Invoke-WebRequest? I do a lot of successive requests and have my own Write-Progress display that I use, so I don't need the built-in one popping up underneath it...
View ArticlePowershell and Task Scheduler - Trigger script if file directory has not...
I've following code to trigger $powershell_code_to_run when file location is not updated for last 30 mins. However, Script is not triggering Start-Process 'C:\windows\system32\mspaint.exe' or...
View ArticleUpload file to SharePoint Document library using powershell
I want to upload the same file to multiple site collections with the same hierarchy in all the site collections. I want to use PowerShell and include auto check-in/check-out functionality.I have able...
View ArticleHow to set Low I/O ("background") priority in Powershell
There's this powershell script which can set processes' priorities from "Idle" to "Realtime" but some tools offer another priority level which drops a process's priority even below:How to set that in...
View ArticleInvoke-Command with -credentials
I want to invoke a command on a remote server, I do not want to have to put in the password to run the script. I've tried encrypting the password and storing it in a txt file. $username =...
View Articlepowershell Exception calling "Replace" with "3" argument(s): "Value cannot be...
While calling this function, I get the exception calling null error.Code:if(Test-Path($Env:TEMP)) { $hsPrefDataDirectories = Get-ChildItem "$Env:TEMP" | where {$_.Name -match "hsperfdata"} |...
View ArticleHow to ensure Export-Csv is in same column order?
I have the following PowerShell code that imports a csv (that has 35 column) and modifies the "Account" column. It's working as expected. However, when I export, it's adding it as the first column when...
View Articlewindows command prompt is showing errror
"C:\Users\Varsha\OneDrive\Desktop\git' is not recognized as an internal or external command,operable program or batch file."this is what it appers when ever i try to copy the path of a folder or a file...
View ArticleHow to add Double quotes to Array elements in Powershell console?
I need to display all elements of the $FileNames array in Powershell console. I am iterating in a For loop but i cant print double quotes to all Array index elements on the console. Please help.Actual...
View ArticleWhy do weekly tasks created via PowerShell using a different user fail with...
We have some scripts that create scheduled jobs using PowerShell as part of our application. When testing them recently, I noticed that some of them always failed immediately, and no output is ever...
View ArticleUnable to connect to Remote Server when we pass credentials as secure string...
Unable to connect to Remote Server when we pass credentials as secure string but able to login when we are manually entering the password instead of converting into string.The script i am using as...
View ArticlePassing admin credentials in Start-Process cmdlet
I am trying to build a script that installs an application with encrypted local admin credentials on the pc when the user logged in is not an admin.I am running the below cmdlet:$User =...
View ArticleDownloadString with basic auth similar to psget's
Anyone know how I can modify the DownloadString below so I can pass basic auth credentials as well?I am using the same technique used for PsGet (http://psget.net/) to download my own internal scripts...
View ArticleI am trying to get-adgroupmember from ad groups created in the last 30 days:
$groups = "TWA_NDL_ObsApp_WR_MAN", "TWA_NDL_ObsApp_WR", "TWA_NDL_ObsApp_WH_MAN"$users = Get-ADUser -Filter "(whenCreated -ge '$((Get-Date).AddDays(-30))')" -Properties whenCreated, memberOf |...
View ArticleHow to execute a CMD file in remote computer
I am looking to execute a command in remote machine using invoke but the .cmd file will call for additional .vbs script. So i guess i may have to mention CScript if so how do i mention both cmd/c and...
View ArticleA PowerShell Script to install fonts on Windows 11
I would like help with the following ps script that I took from reddit to install fonts for all Windows 11 users, below is the original script:#set font source location$FontFolder = "FONT...
View ArticleFetch all the files in a folder but exclude all the files in a sub folder by...
I have a powershell script to fetch all the files in a folder but exclude all the files in a sub folder. I am using the following script, but not giving the expected results.Get-ChildItem -Path...
View Article