Avoid Select-Object output on screen

Advertisements I am having a bit of trouble with Select-Object. With the following piece of (truncated) code: $totalData=(Get-Content $Env:TEMP\FBIUtemp2.txt) ….. $data="" …. …. $data =($totalData | Select-Object -Index ($s..$limit)) $data.Replace("`r`n"," ") $data.Replace("`n"," ") I get a String (list of String separated with newline termination) from a file and get lines between $s and $limit into… Read More Avoid Select-Object output on screen

How to store variable and use it as a -Pattern from Get-Content?

Advertisements Trying to check if few software are installed, when I use this code, it works fine: $Pattern = "Winr","adobe";$software = get-package | Select-Object Name; $array = @($software.name) | Set-Content C:\temp\installed.txt; $SEL = Select-String -Path C:\temp\installed.txt -Pattern $Pattern; if ($SEL -ne $null) {write-host Found => $SEL.Line} else {write-host Nothing Found} This code works without issues,… Read More How to store variable and use it as a -Pattern from Get-Content?

Issue with retrieving data from Graph API to PowerShell

Advertisements I’m starting to work with PowerShell scripts and I’m having an issue with user.accountEnabled. I found out that I need to use the appropriate select statement when retrieving data, so I’m using https://graph.microsoft.com/v1.0/users/?$select=displayname,accountEnabled,userPrincipalName I’m using the app ID and app secret, and I confirmed in Postman (using the same credentials) that I’m getting correct… Read More Issue with retrieving data from Graph API to PowerShell

Powershell, rename at -Destination a folder copied with its content: is it possible with 1 command?

Advertisements I’m copying a folder with its content to another dir. like this: Copy-Item -Path "C:\docs1\article-title-master" -Destination "C:\docs2\articles" -recurse -Force Is it possible with 1 command also to rename folder article-title-master at -Destination? At -Destination only, not in -Path. Thanks! >Solution : You can simply change the name of the folder in -Destination like this… Read More Powershell, rename at -Destination a folder copied with its content: is it possible with 1 command?