powershell

Powershell WSB Script

纵然是瞬间 提交于 2021-01-29 05:35:48
问题 I have a backup script WSBREPORT which works fine. However, I am using an SMTP server that needs authentication. So I have a script separately that works and creates an encrypted txt file with the password. What I can't seem to achieve is to add the authentication script into my backup script. Could you point me into the direction where my script needs to go to get it working, please. ************Working authentication Script *********** $AdminName = "username" $Pass = Get-Content "C:\Masters

Clean/Purge an Exchange Online Mailbox using PowerShell - Post 1st July 2020

≯℡__Kan透↙ 提交于 2021-01-29 05:11:42
问题 On 1st July 2020 Microsoft have retired the Search-Mailbox cmdlet. This functionality allowed for the purging of all content in a mailbox e.g. Search-Mailbox -Identity joe.bloggs@domain.com -DeleteContent The above functionality worked great, however it has been retired. The recommended way forward is to use New-ComplianceSearch, Start-ComplianceSearch and New-ComplianceSearchAction. This seems all good until you read the documentation at https://docs.microsoft.com/en-us/exchange/policy-and

Unable to export user and emplyeeid from ldap group

只愿长相守 提交于 2021-01-29 05:04:22
问题 I am trying to export user and employeeid from LDAP. All the users are in a group that I extracted using the code bellow. I also put them in a csv file. How can I retrieve employeeid for each user ? Changing this query or creating a new one and using the csv file. $groups = @() $groups = 'CONBR-MES-DEV-USERS' Write-Host 'Group_Name','Member' foreach ($group in $groups) { $members = @() $members = Get-ADGroupMember -Server la.jnj.com -Identity $group foreach ($member in $members) { Write-Host

PowerShell Closing FileStream

心已入冬 提交于 2021-01-29 04:57:46
问题 I am reading in a file, encrypting the contents, and writing the cipher text back out to a file using PowerShell. When the FileStream object ($inFS) is closed, it creates a file in the pwd (C:\docs) named "0". I opened the file and it had "32" written to it. The encrypted contents are being written to a file in a different directory with no problems. I thought maybe there was something in the buffer still so I tried Flush() and Dispose() but same results. Why is this? $inFile = 'C:\docs

Replacing a block of text in powershell

旧巷老猫 提交于 2021-01-29 04:57:28
问题 I have the following (sample) text: line1 line2 line3 I would like to use the powershell -replace method to replace the whole block with: lineA lineB lineC I'm not sure how to format this to account for the carriage returns/line breaks... Just encapsulating it in quotes like this doesn't work: {$_ -replace "line1 line2 line3", "lineA lineB lineC"} How would this be achieved? Many thanks! 回答1: There is nothing syntactically wrong with your command - it's fine to spread string literals and

PowerShell - Find and replace multiple patterns to anonymize file

↘锁芯ラ 提交于 2021-01-29 04:45:56
问题 I need you help. I have a log.txt file with various data in it which I have to anonymize. I would like to retrieve all these "strings" matching a predefined patterns, and replace these by another values for each of them. What is important is that each new string from the same pattern (and with different value from the previous) should be replaced by the predefined value increased by +1 (e.g. "orderID = 123ABC" becomes "orderID = order1" and "orderID=456ABC" becomes "orderID=order2"). The

PowerShell - Find and replace multiple patterns to anonymize file

北城余情 提交于 2021-01-29 04:36:10
问题 I need you help. I have a log.txt file with various data in it which I have to anonymize. I would like to retrieve all these "strings" matching a predefined patterns, and replace these by another values for each of them. What is important is that each new string from the same pattern (and with different value from the previous) should be replaced by the predefined value increased by +1 (e.g. "orderID = 123ABC" becomes "orderID = order1" and "orderID=456ABC" becomes "orderID=order2"). The

Powershell Switch Statement String Match Not Working

南楼画角 提交于 2021-01-29 04:35:12
问题 I am having trouble getting a simple switch statement to work in a Powershell script I'm using. Had previously been using nested ifs and wanted to clean up a bit. Code is below. When I walk it through Powershell ISE in debug and evaluate the tests (e.g. $_ -match 'match1' ) it does evaluate to true as expected based on the value of $mystring. However, it never seems to properly execute the code associated with that value in the Switch block. I'm sure I'm missing something obvious, and

An object at the specified path C:\Users\user~1.name does not exist

不问归期 提交于 2021-01-29 04:21:14
问题 So today I came across an issue whereby a powershell script was causing the deployment to fail. This job is set-up exactly the same on other machines. This one however just refused to work. The error was: An object at the specified path C:\Users\user~1.name does not exist heres the full log at the time of failure 2017-01-11T15:03:12.1295730Z Executing the powershell script: D:\Tfs\Agent2\tasks\PowerShellOnTargetMachines\1.0.25\PowerShellOnTargetMachines.ps1 2017-01-11T15:03:12.3014605Z ##

Export only visible rows to CSV with Powershell

拥有回忆 提交于 2021-01-29 04:16:16
问题 I have logic in an Excel macro that parses the documents and hides rows that don't have data in certain cells per row. Looking to export only the visible cells to CSV. I have code (below) to export everything, but how do I make it only do visible rows? $oWorksheet = $objExcel.Worksheets.item(6) $oWorksheet.Activate() "saving $filecsv" $oWorksheet.SaveAs($filecsv,[Microsoft.Office.Interop.Excel.XlFileFormat]::xlCSVWindows) $workbook.Saved = $true 回答1: Please see this answer I believe you could