RSS

Author Archives: NesiSamurai

Windows: Export EventLog from command line

(Copy pasted from: michlstechblog.info)

Windows has a builtin command line utility to deal with Eventlogs: wevtutil

Some examples.

List all registered Eventlogs
D:> wevtutil el


Export the System EventLog to a file
D:> wevtutil epl System c:\%Computername%_System_log.evtx

Export the Application EventLog to a file
D:> wevtutil epl Application c:\%Computername%_Application_log.evtx

Or the Remote Desktop EventLog to a file
D:> wevtutil epl Microsoft-Windows-RemoteDesktopServices-RdpCoreTS/Operational c:\%Computername%_rdp_log.evtx


Search the last 100 Entries in Application EventLog for an Event with ID 1704 as Text
D:> wevtutil qe Application /q:”Event/System/EventID=1704″ /c:100 /f:text

(%Computername% will be replaced by the name of your computer in exported files name)

 
Leave a comment

Posted by on September 7, 2021 in Windows

 

VCRUNTIME140_1.dll not found error when opening Excel

Solution: download and install both the x86 and x64 versions of the Microsoft Visual C++ 2015 – 2019 Redistributable, that should resolve this

Download page

x86: vc_redist.x86.exe

x64: vc_redist.x64.exe

 
Leave a comment

Posted by on August 28, 2021 in excel

 

Outlook 365 – “Need password” but no prompt when clicked – issue

(below details are copy-pasted from Microsoft forum)

POST 1:

Some of our users’ outlook stop sync with exchange and ask for password, as shown in below image:

thumbnail image 1 of blog post titled 
	
	
	 
	
	
	
				
		
			
				
						
							Outlook (365) Need Password - Issue
							
						
					
			
		
	
			
	
	
	
	
	

	
	
	 
	
	
	
				
		
			
				
						
							Re: Outlook (365) Need Password - Issue
							
						
					
			
		
	
			
	
	
	
	
	

	
	
	 
	
	
	
				
		
			
				
						
							Re: Outlook (365) Need Password - Issue
							
						
					
			
		
	
			
	
	
	
	
	

	
	
	 
	
	
	
				
		
			
				
						
							Re: Outlook (365) Need Password - Issue
							
						
					
			
		
	
			
	
	
	
	
	

	
	
	 
	
	
	
				
		
			
				
						
							Re: Outlook (365) Need Password - Issue
							
						
					
			
		
	
			
	
	
	
	
	

	
	
	 
	
	
	
				
		
			
				
						
							Re: Outlook (365) Need Password - Issue
							
						
					
			
		
	
			
	
	
	
	
	

	
	
	 
	
	
	
				
		
			
				
						
							Re: Outlook (365) Need Password - Issue
							
						
					
			
		
	
			
	
	
	
	
	

	
	
	 
	
	
	
				
		
			
				
						
							Re: Outlook (365) Need Password - Issue
							
						
					
			
		
	
			
	
	
	
	
	

	
	
	 
	
	
	
				
		
			
				
						
							Re: Outlook (365) Need Password - Issue
							
						
					
			
		
	
			
	
	
	
	
	

	
	
	 
	
	
	
				
		
			
				
						
							Re: Outlook (365) Need Password - Issue
							
						
					
			
		
	
			
	
	
	
	
	

	
	
	 
	
	
	
				
		
			
				
						
							Re: Outlook (365) Need Password - Issue
							
						
					
			
		
	
			
	
	
	
	
	

	
	
	 
	
	
	
				
		
			
				
						
							Re: Outlook (365) Need Password - Issue
							
						
					
			
		
	
			
	
	
	
	
	

	
	
	 
	
	
	
				
		
			
				
						
							Re: Outlook (365) Need Password - Issue
							
						
					
			
		
	
			
	
	
	
	
	

	
	
	 
	
	
	
				
		
			
				
						
							Re: Outlook (365) Need Password - Issue
							
						
					
			
		
	
			
	
	
	
	
	

	
	
	 
	
	
	
				
		
			
				
						
							Re: Outlook (365) Need Password - Issue
							
						
					
			
		
	
			
	
	
	
	
	

	
	
	 
	
	
	
				
		
			
				
						
							Re: Outlook (365) Need Password - Issue
							
						
					
			
		
	
			
	
	
	
	
	

	
	
	 
	
	
	
				
		
			
				
						
							Re: Outlook (365) Need Password - Issue
							
						
					
			
		
	
			
	
	
	
	
	

	
	
	 
	
	
	
				
		
			
				
						
							Re: Outlook (365) Need Password - Issue
							
						
					
			
		
	
			
	
	
	
	
	

	
	
	 
	
	
	
				
		
			
				
						
							Re: Outlook (365) Need Password - Issue
							
						
					
			
		
	
			
	
	
	
	
	

	
	
	 
	
	
	
				
		
			
				
						
							Re: Outlook (365) Need Password - Issue

But when we press the “Need Password” button, nothing happens. there is no prompt.

to fix the issue, I clear entries in Credential Manager, Delete Temporary Files, unchecked “Use Cached Exchange mode”, restart system and check this again.

POST 2: (Confirmed accepted answer)

There are a number of reasons for this. First I would look inside the Office 365 admin portal to make sure your password expiration policy is not set to only a few days

If this is ok, setting the below registry key to 1 in below path often resolves it

Path: HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Common\Identity
Key: DisableADALatopWAMOverride (DWORD)

This key may not exist, we need to create it.

 
Leave a comment

Posted by on August 28, 2021 in Uncategorized

 

Excel Remove some letters from a cell and extract some values from the rest.

In a specific situation where you want to remove the certain number of characters from a cell, and you want to take a part of the number out. You can use this formula.

Example: I have a cell with this value 0107856985652HJKG. I need to remove the first three values, then take the next 10 characters out.

010 7856985652 HJKG

=LEFT((RIGHT(CellWithYourValue,LEN(CellWithYourValue)-NumberOfLettersToRemoveFromBeginning)),NumberOfLettersToTakeAfterRemoval)

If my value wan in cell A1 the formula will look like this ==>

=LEFT((RIGHT(A1,LEN(A1)-3)),10)

 
Leave a comment

Posted by on August 17, 2021 in excel, Windows

 

Split A Workbook To Separate Excel Files With VBA Code

The following VBA code can help you quickly split multiple worksheets of current workbook to separate Excel files, please do as follows:

1. Create a new folder for the workbook that you want to split, because the split Excel files will be stayed at the same folder as this master workbook.

2. Hold down the ALT + F11 keys in Excel, and it opens the Microsoft Visual Basic for Applications window.

3. Click Insert > Module, and paste the following code in the Module Window.

VBA: Split a workbook into multiple workbooks and save in the same folder

Sub Splitbook()
'Updateby20140612
Dim xPath As String
xPath = Application.ActiveWorkbook.Path
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For Each xWs In ThisWorkbook.Sheets
    xWs.Copy
    Application.ActiveWorkbook.SaveAs Filename:=xPath & "\" & xWs.Name & ".xlsx"
    Application.ActiveWorkbook.Close False
Next
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub

4. Click F5 to run the code

(Above info is copied from here >> external link)

 
Leave a comment

Posted by on August 7, 2021 in Uncategorized

 

Google Sheets – Add a Pop-Up Calendar Date Picker

Step 1: Select the cells where you want the pop-up then from menu Data> validation

Step 2: select date from validation criteria and click save

OK now when you click the selected cell from step 1 you will get a pop-up calender.

 
Leave a comment

Posted by on June 14, 2021 in Uncategorized

 

HikVision devices Naming Rules

 
Leave a comment

Posted by on June 2, 2021 in Uncategorized

 

Bulk add alias in Microsoft 365 Exchange using powershell.

The following steps will add a new alias to given emails. It will not make the new alias as primary.

  1. Open a persistant session to the exchange.
    $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection

02.Import the session to your powershell:
Import-PSSession $Session

03.Login to Microsoft 365 admin account
Connect-Msolservice

  1. Download Global address list.
    get-user -resultsize unlimited |select * |export-csv c:\M365\users.csv
  2. Delete all columns except “Identity”.
  3. Add a new column named “Alias”.
  4. After updating the sheet run the following script.

$Recipients = Import-Csv C:\M365\users.csv
Foreach ($Item in $Recipients)
{
Set-Mailbox -Identity $Item.Identity -EmailAddresses @{Add=$Item.Alias}
}

(This note is based on what I did today. I have very little understanding of powershell, if you are going to try these steps please do your research first.)

 
Leave a comment

Posted by on May 31, 2021 in Uncategorized

 

Bulk Update User information in Microsoft 365 Exchange using powershell.

Note for future reference:

  1. Open a persistant session to the exchange.
    $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection

It will ask for your credentials.

  1. Import the session to your powershell:
    Import-PSSession $Session
  2. Login to Microsoft 365 admin account (to use MsolUser Cmdlet)
    Connect-Msolservice (It will ask for your credentials.)
  3. Download the contents of your Exchange Global Address list to a CSV file
    get-user -resultsize unlimited |select * |export-csv c:\MS365\users.csv
  4. Remove unneccessry columns and edit what you need. (dont delete the columns named UserPrincipalName and Identity we need to use them later.)
    In this usecase I will use Set-MsolUser module, which supports the following options.

Set-MsolUser
[-ImmutableId ]
[-ObjectId ]
[-UserPrincipalName ]
[-BlockCredential ]
[-City ]
[-Country ]
[-Department ]
[-DisplayName ]
[-Fax ]
[-FirstName ]
[-LastName ]
[-LastPasswordChangeTimestamp ]
[-MobilePhone ]
[-Office ]
[-PasswordNeverExpires ]
[-PhoneNumber ]
[-PostalCode ]
[-PreferredDataLocation ]
[-PreferredLanguage ]
[-SoftDeletionTimestamp ]
[-State ]
[-StreetAddress ]
[-StrongPasswordRequired ]
[-Title ]
[-UsageLocation ]
[-AlternateEmailAddresses ]
[-StrongAuthenticationMethods ]
[-AlternateMobilePhones ]
[-StrongAuthenticationRequirements ]
[-StsRefreshTokensValidFrom ]
[-UserType ]
[-TenantId <Guid>]

  1. After updating the CSV, import the updated csv to powershell and execute the changes.

in the below script, header names referenced with a hyphon are the names we used in our sheet. header names referenced with $_. are the ones that the exchange is expecting from us. To make it simpler I used the same names as exchange in my sheet.

to map a field to a field in exchange we use this syntax : – $_.

Import-Csv C:\M365\users.csv | foreach{Set-MsolUser -UserPrincipalName $_.UserPrincipalName -DisplayName $_.DisplayName -FirstName $_.FirstName -LastName $_.LastName -City $_.City -StreetAddress $_.StreetAddress -Department $_.Department -Country $_.Country -MobilePhone $_.MobilePhone}

supported field names are shown in step 5.

In this script we are using UserPrincipalName as the main reference.

After running this script it takes a few minutes to be able to see your changes in the Exchange Admin portal.

(This note is based on what I did today. I have very little understanding of powershell, if you are going to try these steps please do your research first.)

 
Leave a comment

Posted by on May 31, 2021 in Uncategorized

 

EXCEL: How to get number from any position in a string

Copy pasting as found on another website for future reference. (Link to website)

If your task implies extracting number from anywhere in a string, you can make use of the following mind-boggling formula published on MrExcel forum:

=SUMPRODUCT(MID(0&A2, LARGE(INDEX(ISNUMBER(--MID(A2, ROW(INDIRECT("1:"&LEN(A2))), 1)) * ROW(INDIRECT("1:"&LEN(A2))), 0), ROW(INDIRECT("1:"&LEN(A2))))+1, 1) * 10^ROW(INDIRECT("1:"&LEN(A2)))/10)

Where A2 is the original text string.

Breaking down this formula would require a separate article, so you can simply copy it to your worksheet to make sure it really works 🙂
Formula to get number from any position in a string

Upon examining the results, however, you may notice one insignificant drawback – if the source string does not contain a number, the formula returns zero, as in row 6 in the screenshot above. To fix this, you can wrap the formula in the IF statement, the logical test of which checks if the source string contains any number. If it does, the formula extracts the number, otherwise returns an empty string:

=IF(SUM(LEN(A2)-LEN(SUBSTITUTE(A2, {"0","1","2","3","4","5","6","7","8","9"}, "")))>0, SUMPRODUCT(MID(0&A2, LARGE(INDEX(ISNUMBER(--MID(A2,ROW(INDIRECT("$1:$"&LEN(A2))),1))* ROW(INDIRECT("$1:$"&LEN(A2))),0), ROW(INDIRECT("$1:$"&LEN(A2))))+1,1) * 10^ROW(INDIRECT("$1:$"&LEN(A2)))/10),"")

As shown in the screenshot below, the improved formula works beautifully (kudos to Alex, our Excel guru, for this improvement):

An improved formula to extract number from anywhere in a string

Unlike in all previous examples, the result of this formula is number. To make sure of this, just notice the right-aligned values in column B and truncated leading zeros.

Credit: ablebits.com

 
Leave a comment

Posted by on May 29, 2021 in Uncategorized