Category "powershell"

Invoke-Restmethod: how do I get the return code?

Is there a way to store the return code somewhere when calling Invoke-RestMethod in PowerShell? My code looks like this: $url = "http://www.dictionaryapi.com/

Using Get-ChildItem -Exclude or -Include returns nothing

I have a list in my C: directory that has many files. If I try to run an -Exclude on it, I get no returns. Same with -Include. If I use filter it returns what I

Take Excel cell content and place it into a formatted .txt file

So I have an Excel document, which is essentially a table. For the purposes of this, we will use this: Dummy Data What I'm wanting to do is take the values fr

Export members of multiple groups

Is it possible to change the PS script below in two ways: The group members are now exported horizontally but I want all the users in 1 cell in the column besid

How to stop a windows 10 machine from sleeping/hibernating down when running a powershell process?

I have a powershell process that reads records from a remote server and copies them into a local database. When it runs, it might run for 8-12 hours. How do I p

Cannot start service on computer '.'

I'm trying to create and start a windows service using PowerShell. The service is created but cannot be started when I use various names besides one particular

How to enable auditing on subfolders and files using powershell

I tried to enable the audit policy on folder using powershell script. But in my case the audit policy is not applied for subfolders and files within the folder

Team Foundation Server(Release Pipeline)

I'm developing Release pipeline for deploying artefacts using TFS 2017 Update3 Release Management. There are various tasks like "Windows Machine File Copy" and

Get date and time on the same line

I can use date /t and time /t to get the date and time, but it doesn't display it next to each other. I wanted to make it do that and display like this: Curren

How do I remove the cruft at the start of my posh-git window title?

I'm using posh-git for my powershell window, and the prompt is perfect: S:\Repos\DevTools [master ≡ +1 ~2 -0 !]> But the title of the window has ext

convert "Yes" or "No" to boolean

I want to parse user values contained in .CSV file. I don't want my users to enter "Yes" or "No" but instead enter "True" or "False". In each case I want to c

PowerShell Version check prior to script execution

I'm just asking the communitty if they have come across a way to have the a script check what version of POSH is running prior to the execution of the script.

How can I pull Mail Contact groups for each contact with powershell?

I am trying to create a script to pull contact groups and put them in an excel sheet. Here is what I have so far: Import-Module ActiveDirectory Get-ADUser -Sea

Datadog Agent installation on Windows

I am trying to install the Datadog agent on Windows using PowerShell only, not manual however, the APIKEY is not being setup. Is there a way to update/set the A

Get the last command executed on a PowerShell script

I'm updating the logging function I use for all my scripts and making it compatible with the SCCM logging viewer. Under the fields that the SCCM viewer takes i

Specifying complete installation option when running msi from powershell

I am trying to automate the installation of gstreamer on windows using powershell I have the msi file downloaded, and am installing it as shown below PS C:\User

Unable to connect to the server: dial tcp: lookup <Server Location>: no such host

I'm beginning to build out a kubernetes cluster for our applications. We are using Azure for cloud services, so my K8s cluster is built using AKS. The AKs clust

How to check if a DateTime value is not null or empty?

I want to check if the DateTime field is not an empty\null string. if datetime field is not null then I will do stuff. [DateTime]$expdate = Read-Host "Expirati

How to get item ID of the last modified item in the SharePoint online list using pnp powershell?

I am able to get the date of the last modified item in the list using the script below: $SiteURL="https://abc.sharepoint.com/sites/sitename" $ListName="Document

Is it possible to use with and endwith instructions?

I am translating vba code to PowerShell Does with and endwith exist in PowerShell? What is the alternative? Could you give me an example?