powershell

Powershell, EWS, OAuth2, and automation

ε祈祈猫儿з 提交于 2021-02-10 11:46:41
问题 I am trying to find documentation on how to implement non-interactive Oauth2 authentication to EWS using PowerShell, but I'm probably not using the correct search terms, because I can't find anything useful. The Microsoft documentation I can find on OAuth2 only has C# documentation. So, does anyone know how to implement this? No user input, should work with input that can be provided as script input Should be in PowerShell, not C# Details! Details! Not 'Now generate a login token', but the

Powershell Convert String With ENV Variable

纵然是瞬间 提交于 2021-02-10 08:39:33
问题 I have the following code: $myVar = 'C:\Users\$env:USERNAME\Desktop' Test-Path "$myVar" The variable $myVar is needed with single quotes to display the actual variables used to the user. How can I then actually process the variable later into the actual path to use? Test-Path $myVar returns False , not seeing the users path "C:\Users\User\Desktop" 回答1: Found it! As the single quotes could not be changed in the original variable $myVar , the following worked to expand its variable later:

Powershell Jobs with SharePoint Connection

♀尐吖头ヾ 提交于 2021-02-10 07:27:23
问题 (Basic desire is to cascade delete files. Also, use the same concept to recurse copy files to SharePoint) How do you pass a SharePoint connection into a PowerShell job. If I use Connect-PNPOnline -ReturnConnection and then pass the variable into the Job as an argument I get the following error. System.Management.Automation.ParameterBindingException: Cannot bind parameter 'Connection'. Cannot convert the "SharePointPnP.PowerShell.Commands.Base.SPOnlineConnection" value of type "Deserialized

Listing all emails on a shared mailbox with attachments name

牧云@^-^@ 提交于 2021-02-10 06:46:33
问题 I have created a very simple powershell script to collect some basic information about all the emails on a shared mailbox folder. Add-type -assembly "Microsoft.Office.Interop.Outlook" | out-null $olFolders = "Microsoft.Office.Interop.Outlook.olDefaultFolders" -as [type] $outlook = new-object -comobject outlook.application $namespace = $outlook.GetNameSpace("MAPI") $Inbox = $namespace.pickfolder() $Inbox.items | Select-Object -Property Categories, Attachments, Subject, ReceivedTime This is

Listing all emails on a shared mailbox with attachments name

回眸只為那壹抹淺笑 提交于 2021-02-10 06:44:24
问题 I have created a very simple powershell script to collect some basic information about all the emails on a shared mailbox folder. Add-type -assembly "Microsoft.Office.Interop.Outlook" | out-null $olFolders = "Microsoft.Office.Interop.Outlook.olDefaultFolders" -as [type] $outlook = new-object -comobject outlook.application $namespace = $outlook.GetNameSpace("MAPI") $Inbox = $namespace.pickfolder() $Inbox.items | Select-Object -Property Categories, Attachments, Subject, ReceivedTime This is

Powershell. Combine properties of objects in array

狂风中的少年 提交于 2021-02-10 06:34:18
问题 I'm not very good at powershell and I need help. I am trying to combine properties of objects. For two objects, everything is fine. This is looks like. $obj1 = [PSCustomObject]@{ 'ip' = '10.10.10.11' 't1' = 'show' 't2' = 'ab' } $obj2 = [PSCustomObject]@{ 'ip' = '10.10.10.11' 't1' = 'me' 't2' = 'cd' } foreach ($prop in $obj2 | Get-Member -MemberType NoteProperty | Where-Object {$_.name -ne 'ip'} | select -ExpandProperty name) { $obj1.$prop += $obj2.$prop } $obj1 Result: ip t1 t2 -- -- -- 10.10

Need to monitor Server Resources Utilization for 30 minutes and send mail in Powershell

亡梦爱人 提交于 2021-02-10 06:14:41
问题 I have developed PowerShell script which monitors server performance like average CPU utilization, Memory and Cdrive and if any of the resource crosses the threshold it will trigger mail. My script is running fine but I want to monitor it for 30 minutes and if in 30 minutes it cross threshold only then it will trigger the mail. <# .SYNOPSIS Script for the detailed server health report .DESCRIPTION The script accepts parameter from CSV file by which we can get details and all information

ARM - How to pass a parameter to commandToExecute with spaces?

你离开我真会死。 提交于 2021-02-10 06:12:19
问题 I am building an ARM template that uses Azure templates for deployment, so that it can be used as 'stock' image for users to deploy. One of the requirements is that an end user inputs the computer description as a parameter. Parameter: "psVariable": { "value": "My Super Awesome Description" } I'm using a Custom Script Extension to execute a PowerShell script that changes the computer description. PowerShell Script: Param ( [string] $psVariable ) New-ItemProperty -Path "HKLM:\SYSTEM

ARM - How to pass a parameter to commandToExecute with spaces?

拟墨画扇 提交于 2021-02-10 06:11:34
问题 I am building an ARM template that uses Azure templates for deployment, so that it can be used as 'stock' image for users to deploy. One of the requirements is that an end user inputs the computer description as a parameter. Parameter: "psVariable": { "value": "My Super Awesome Description" } I'm using a Custom Script Extension to execute a PowerShell script that changes the computer description. PowerShell Script: Param ( [string] $psVariable ) New-ItemProperty -Path "HKLM:\SYSTEM

Log output of ForEach loop

别等时光非礼了梦想. 提交于 2021-02-10 05:55:10
问题 The code below gets computer info remotely. I couldn't get it send output to a log file. Also, how do I log all unqueried computers in a separate log file? Code: $ArrComputers = gc .\computernames.txt Clear-Host ForEach ($Computer in $ArrComputers) { $computerSystem = get-wmiobject Win32_ComputerSystem -Computer $Computer $computerBIOS = get-wmiobject Win32_BIOS -Computer $Computer $Version = Get-WmiObject -Namespace "Root\CIMv2" -Query "Select * from Win32_ComputerSystemProduct" -computer