powershell

Graph API get token

旧巷老猫 提交于 2021-02-11 12:58:13
问题 I am trying to get Graph API token on behal of the user. I am following this document https://docs.microsoft.com/en-us/graph/auth-v2-user and everything works well until the step 3 Get a Token. Here is the code I am using: Add-Type -AssemblyName System.Web $clientIDEncoded = [System.Web.HttpUtility]::UrlEncode($clientid) $redirectUriEncoded = [System.Web.HttpUtility]::UrlEncode("https://login.live.com/oauth20_desktop.srf") $scopeEncoded = [System.Web.HttpUtility]::UrlEncode("https://graph

Graph API get token

[亡魂溺海] 提交于 2021-02-11 12:58:05
问题 I am trying to get Graph API token on behal of the user. I am following this document https://docs.microsoft.com/en-us/graph/auth-v2-user and everything works well until the step 3 Get a Token. Here is the code I am using: Add-Type -AssemblyName System.Web $clientIDEncoded = [System.Web.HttpUtility]::UrlEncode($clientid) $redirectUriEncoded = [System.Web.HttpUtility]::UrlEncode("https://login.live.com/oauth20_desktop.srf") $scopeEncoded = [System.Web.HttpUtility]::UrlEncode("https://graph

How to sort 30Million csv records in Powershell

流过昼夜 提交于 2021-02-11 12:50:54
问题 I am using oledbconnection to sort the first column of csv file. Oledb connection is executed up to 9 million records within 6 min duration successfully. But when am executing 10 million records, getting following alert message. Exception calling "ExecuteReader" with "0" argument(s): "The query cannot be completed. Either the size of the query result is larger than the maximum size of a database (2 GB), or there is not enough temporary storage space on the disk to store the query result." is

How to sort 30Million csv records in Powershell

此生再无相见时 提交于 2021-02-11 12:50:03
问题 I am using oledbconnection to sort the first column of csv file. Oledb connection is executed up to 9 million records within 6 min duration successfully. But when am executing 10 million records, getting following alert message. Exception calling "ExecuteReader" with "0" argument(s): "The query cannot be completed. Either the size of the query result is larger than the maximum size of a database (2 GB), or there is not enough temporary storage space on the disk to store the query result." is

Removing extra blank space from PowerShell output

…衆ロ難τιáo~ 提交于 2021-02-11 12:47:03
问题 I have a PowerShell program to replace some strings with another from an input file but the output file has an extra space/line when compared to input file. $InputACKFile = 'C:\Testing_Newline\Aj*.dat' Write-Host "Found " ($InputACKFile | Measure-Object).Count " files to process" $InputACKFile = Get-ChildItem $InputACKFile foreach ($xfile in $InputACKFile) { Write-Host "Processing file: $xFile`r" #((Get-Content $xfile).Replace("~", "`n")) | Out-File $xfile.FullName [System.IO.File]:

Removing extra blank space from PowerShell output

99封情书 提交于 2021-02-11 12:45:39
问题 I have a PowerShell program to replace some strings with another from an input file but the output file has an extra space/line when compared to input file. $InputACKFile = 'C:\Testing_Newline\Aj*.dat' Write-Host "Found " ($InputACKFile | Measure-Object).Count " files to process" $InputACKFile = Get-ChildItem $InputACKFile foreach ($xfile in $InputACKFile) { Write-Host "Processing file: $xFile`r" #((Get-Content $xfile).Replace("~", "`n")) | Out-File $xfile.FullName [System.IO.File]:

PowerShell Get-ACL with SamAccountName values

好久不见. 提交于 2021-02-11 12:40:34
问题 I'm trying to collect folder permissions to a csv file with Powershell. My problem is that I'd need the results to contain both the SamAccountName and FileSystemRights. I tried two different method. The first I came up with was a simple approach that gave me IdentityReference and FileSystemRights, but I couldn't find any working method that can get SamAccountName from IdentityReference. The second one I found on the internet was much more sophisticated. It collects all the accounts that has

PowerShell Get-ACL with SamAccountName values

半腔热情 提交于 2021-02-11 12:40:24
问题 I'm trying to collect folder permissions to a csv file with Powershell. My problem is that I'd need the results to contain both the SamAccountName and FileSystemRights. I tried two different method. The first I came up with was a simple approach that gave me IdentityReference and FileSystemRights, but I couldn't find any working method that can get SamAccountName from IdentityReference. The second one I found on the internet was much more sophisticated. It collects all the accounts that has

Running powershell in VB.NET - how to access the content of my variable

不想你离开。 提交于 2021-02-11 12:38:04
问题 I am running a simple script in VB using System.Management.Automation as below Script runs fine, but how do I then access content of $offline and $online in my code after it has run? Dim scriptContents = New StringBuilder() scriptContents.AppendLine("$computers = @(""PC-1"", ""PC-2"", ""PC-3"")") scriptContents.AppendLine("$online = @()") scriptContents.AppendLine("$offline = @()") scriptContents.AppendLine("Foreach ($computer in $computers) {") scriptContents.AppendLine("If (Test-Connection

How to - Find and replace the first occurrence only

戏子无情 提交于 2021-02-11 12:34:47
问题 I have a script that seems to work correctly only it works to good. I have files that contain multiple lines with the string "PROCEDURE DIVISION.", with the period at the end. What I need to do... ONLY remove the [2nd occurrence] of the string "PROCEDURE DIVISION." if it's in the text file twice and bypass the file if it is only found once. I need to preserve the 1st occurrence and change/remove the 2nd occurrence. I can find and replace all the occurrences easily, I have no clue how to