- ##Powershell Test
- ## parameter declarations
- param (
- [string]$DateFrom = $( Read-Host "Input Last Date Updated, format YYYY-MM-DD" ),
- [string]$DateTo = $( Read-Host "Input Date to Update To (Leave blank for today), format YYYY-MM-DD" )
- )
- $DateTo = "_$DateTo";
- $matches = @()
- ## WebRequest Section. Deprecated, Use Invoke-WebRequest in PS 3.0 and higher
- $HTTPRequest = "https://appstest.mclaneco.com/employee-photo-booth/rest/image/queries/update/activedirectory/$DateFrom$DateTo"
- $WebRequest = [System.Net.WebRequest]::Create("$HTTPRequest")
- $WebRequest.Method = "GET"
- $WebRequest.ContentType = "application/json; charset=utf-8"
- $Response = $WebRequest.GetResponse()
- $ResponseStream = $Response.GetResponseStream()
- $ReadStream = New-Object System.IO.StreamReader $ResponseStream
- $Data=$ReadStream.ReadToEnd()
- ## Filters Input and seperates each userId=employeeId, to a PSObject
- $matches += $Data | Select-String -Pattern '([a-zA-Z0-9]{3,8})=([0-9]{9})' -AllMatches |
- ForEach-Object {$_.matches} | ForEach-Object {New-Object PSObject -Property @{
- UsrID = $($_.groups[1]);
- EmpID = $($_.groups[2]);
- }};
- Write-Host $HTTPRequest;
- ## Checks to see if the photo directory is available for an employee ID, switch to production file path for final result
- ForEach($match in $matches){
- $ChkFile = "\\vserver-appdata01.mclane.mclaneco.com\test_emp_photos$\Photos\$($match.EmpID)";
- $FileExists = Test-Path $ChkFile;
- if($FileExists -eq $True){
- Write-Host "$($match.UsrID) -> $($match.EmpID)"
- Write-Host "Has Image Dir";
- }
- }
Trying to Array information into .csv file. I would like to put the member in a csv
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
- cgjackson@yahoo.com
- Posts: 7
- Last visit: Tue Aug 07, 2018 5:16 am
Trying to Array information into .csv file. I would like to put the member in a csv
- Attachments
-
- dPhotoTest.ps1
- Works with results window, but I am have problem getting it to a file.
- (1.57 KiB) Downloaded 105 times