RSS

Author Archives: NesiSamurai

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

 

HP Server Windows 2019 ROK bios lock error [Solution]

This error happened when I tried to install Win server 2019 ROK on an HP server(vmware esxi). This happens when the vm does not see the motherboard.

Solution: Download the vmx file for your vm. add the following line and then upload. thats all.

SMBIOS.reflectHost= "TRUE"
 
Leave a comment

Posted by on May 19, 2021 in Windows

 
Image

Zkteco F18 with ElectricLock+PushButton

In this diagram you can see how to install Zkteco F18 with Door lock and push button.

  • Connect NC (Yellow) of F18 to +ve (Red) on Door Lock.
  • Connect COM(Red) and +ve(Red) of F18 to +ve of the power supply (12v 3A)
  • Connect both the -ve (Black) of F18 and -ve (Black) of Door Lock to -ve of Power supply.
  • Connect BUTTON (Grey) of F18 to 1 of the connections in Push button.
  • Connect the other connection on the button to -ve of Power supply.
 
Leave a comment

Posted by on April 25, 2021 in Uncategorized

 

Disable USB mass storage access on client machines

  1. Go to the client machine and
  2. go to start button and type in to search box gpedit.msc
  3. then your group policy window will open
  4. left side of window – search Administrative Templates and double click on it
  5. then click on System
  6. next you will see Removable Storage Access just click on it
  7. then you will see lots of group policy name
  8. see the All Removable Storage Access: Deny All Access
  9. double click on it and select the option Enable and click on OK button
  10. you will success to block USB of client

Then from cmd run ==> gpupdate /force

 
Leave a comment

Posted by on January 30, 2021 in Uncategorized

 

Open sections of Control Panel from CMD

  • Accessibility Options control windows+R > access.cpl
  • System properties, Add domain, change name windows + R > sysdm.cpl
  • Add/Remove Programs windows + R > appwiz.cpl
  • Display Properties windows+R> desk.cpl
  • Date/Time Properties w+R> timedate.cpl
  • Fonts Folder WQ+R> fonts
  • Network properties W+R > ncpa.cpl
  • Regional Settings control intl.cpl





Internet Properties            windows+R > inetcpl.cpl
Joystick Properties            windows+R > joy.cpl
Keyboard Properties            windows+R > main.cpl keyboard
Microsoft Exchange             windows+R > mlcfg32.cpl
   (or Windows Messaging)
Microsoft Mail Post Office     windows+R > wgpocpl.cpl
Modem Properties               windows+R > modem.cpl
Mouse Properties               windows+R > main.cpl
Multimedia Properties          windows+R > mmsys.cpl
Network Properties             windows+R > netcpl.cpl
                               NOTE: In Windows NT 4.0, Network
                               properties is Ncpa.cpl, not Netcpl.cpl
Password Properties            control password.cpl
PC Card                        control main.cpl pc card (PCMCIA)
Power Management (Windows 95)  control main.cpl power
Power Management (Windows 98)  control powercfg.cpl
Printers Folder                control printers

Scanners and Cameras           control sticpl.cpl
Sound Properties               control mmsys.cpl sounds
System Properties              control sysdm.cpl
 
Leave a comment

Posted by on January 30, 2021 in Windows

 

Virtualenv in PowerShell for python

Today I was following a tutorial about Flask for python. While doing this I ran into a problem. I created a folder for my project. Then installed virtual environment module.

pip install virtual env 

ran successfully, module virualenv is now installed

virtualenv env 

this command also ran successfully. a virtual environment with name env is created.

so we have created a virtual environment. now to activate we need to run a batch file form inside the env folder.

env\Scripts\activate.bat

This will not run in power-shell because its a batch file.

so I tried the next option.

 env\Scripts\activate.ps1 

this gave an error.

.\env\Scripts\activate.ps1 : File D:\Userfiles\Desktop\Py Flask\env\Scripts\activate.ps1 cannot be loaded because running scripts is disabled on this system. For more
information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.

so how to activate our virtual environment?

lets remove the restriction.

 Set-ExecutionPolicy -Scope CurrentUser RemoteSigned 

the above command will enable running scripts for current user. we can disable this with the following command after we finish.

Set-ExecutionPolicy -Scope CurrentUser Restricted

running scripts is now enabled. lets try again.,with

.\env\Scripts\activate.ps1

It works! yay..

 
Leave a comment

Posted by on January 25, 2021 in Python

 

Tags: , , ,

Website hosting Name.com and iPage

In this post I will write down how to host a website at iPage and route a domain from name.com to the hosting.

  • add an A record in name.com pointing to iPage hosting server IP.
  • in iPage go to Domains ==> import domain
  • on the next screen select add existing domain. (Add your domain but keep your current registrar.)

no we if someone opens your domain, DNS will point to name.com A record. Thus traffic is forwarded to iPage hosting. Now traffic reaches the server, but we need to route the traffic to the website directory. To do this we need to add a pointer in our hosting. But by default this option is not shown on our dashboard.

All domains you added to your iPage hosting will be listed here, select the domain you want to add the pointer.

You will see these options. Select pointers.

Select Subdirectory ==> /folder_where_your_website_files_are_stored.

Now the traffic is routed to your website directory.

You need to change any domain reference in your website files. for example if you are using a wordpress template, inside wp-admin you may have assigned a domain URL, when you change the domain maping on iPage you must also change the same inside your code as well.

How do I change the WordPress Site URL?

 
Leave a comment

Posted by on January 19, 2021 in Uncategorized