Search This Blog

Thursday, June 29, 2023

Windows Terminal (wt.exe) - Powershell with SSH terminal emulation

 wanted to get openssh to format correctly in powershell.

Discovered that you can change the terminal emulation using the environment variable.

$env:TERM = 'xterm'


But wanted to just have this applied when I started the session.

So using the Windows Terminal I created a new profile (duplicating the pwsh profile).

Then changing the Command Line to 

"C:\Program Files\PowerShell\7\pwsh.exe" -noexit -command "& {$env:TERM='xterm';}"


Share/Bookmark

Wednesday, September 29, 2021

Windows Terminal - Add to context menu.

Windows Terminal is a windows APP so is a little different than normal programs. I am not an expect but just include this info for some background.

Windows terminal runs a wt.exe

it can be found here..

%LOCALAPPDATA%\Microsoft\WindowsApps\wt.exe


So to do what we want we have to override some settings in the config of the wt.exe. These can be found here.. This may change depending on what version of the windows terminal you  have installed.. I have the preview...

%LOCALAPPDATA%\Packages\Microsoft.WindowsTerminalPreview_8wekyb3d8bbwe\LocalState

but could be 

%LOCALAPPDATA%\Packages\Microsoft. WindowsTerminal_8wekyb3d8bbwe\LocalState\

So we need to add this line 

"startingDirectory"null

to the settings.json file...

"profiles":
    {
        "defaults":
        {
            // Put settings here that you want to apply to all profiles.
            "startingDirectory"null
        },


Then we can update the registry to add an entry to the right click context menu.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt]
@="Open Windows Terminal here"
"ShowBasedOnVelocityId"=dword:00639bc8
"Extended"=""

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt\command]
@="%LOCALAPPDATA%\\Microsoft\\WindowsApps\\wt.exe"

And now we should be good.. Right click on a folder and there should be an option







Share/Bookmark

Saturday, March 27, 2021

MX Linux - Netgear A6210 driver install.

Putting this here so I don't have to go searching again....
 

Tried to get a couple of usb adapters installed on MX linux (buster).

Initially i started with older TP-link USB adapaters 

TL-WN821N and TL-WN822N

However whilst the driver would install and the device was listed in lsusb output, I could never get it working...


In the end I swapped to a netgear adapter A6210.

Using the following articles as reference I was able to get this working.

https://community.netgear.com/t5/WiFi-Adapters/Netgear-A6210-compiling-Linux-driver/td-p/1711232

https://community.netgear.com/t5/WiFi-Adapters/A6210-ADAPTER-ON-LINUX-UBUNTU/td-p/1062677


But these are the commands I used to install this.

git clone -b port-to-4.15 https://github.com/kaduke/Netgear-A6210.git

cd Netgear-A6210

make

sudo make install

 

I got some warnings during the compile, but everything worked when I plugged the usb adapter in.



Share/Bookmark

Monday, February 22, 2021

Setup email alias for user to send from (Exchange\Excahnge Online - Hybrid)

 Had a request to setup a new domain for some new users. The intention was to allow these users to send from this domain to external users.

We operated a hybrid setup with Office365, and adding additional domains to this setup is pretty straight forward and there are tutorials on how to do this.. Pretty much add the domains to both side (exchange on premise, Exchange online and then run the Hybrid Config Wizard (HCW)).

An issue arises though when a user tries to send from the new domain email address. Whilst it will let them send it, when the email routes through exchange it will pick up the primary email address.. I thought I could force the reply to address to be the new email, but that didnot work, and the email arrives at the recipient and lists the primary email address..

So how to get round this...

It appears the only way around this is to setup the account to allow it to "send as" another email.. So there are two options shared mailbox, delegation group.

I chose the delegation group as I didn't want to create another mailbox. So I removed the alias from the user. Setup a delegation group and assigned the new email to that delegation group. Then gave "send as" permissions to the existing user to the new delegation group.

These permissions need to be setup both sides..

New-DistributionGroup -Name "(Display name for DG will appear in outlook)" -type Distribution -Members "(existing AD user)" -managedby "(existing AD user)" -PrimarySmtpAddress "user@new.domain" -OrganizationalUnit "domain/ou1/ou2/ou...."

Exchange (on-premise)

Add-ADPermission -Identity "(Display name for DG will appear in outlook)" -User "(existing AD user)" -AccessRights ExtendedRight -ExtendedRights "Send As"

Run AAD Connect (DirSync)

Exchange Online

connect-exchangeonline

Add-RecipientPermission -Identity "(Display name for DG will appear in outlook)" -Trustee "(existing AD user)" -AccessRights SendAs




Share/Bookmark

Monday, January 11, 2021

Event Triggered Scheduled Task - On Process Start

I wanted to run a powershell script when a specific process started.

I knew you could create event triggered scheduled tasks, and have used this before based on a specific event id.. However this time the eventid is going to be the same for a lot of different process start events so needed to find a way to filter this. Turns out you can edit the filter manually in Task Scheduler and this allows you to fully edit the XPath queries of the event XML.

To enable this, you must first turn on Audit Process Tracking for Success, in Local Security Policy


Now in the scheduled tasks

Edit the event filter, the query is below. You can get the field and values from looking at the XML in the event viewer under eventdata
this is the line in the query below that will need to be updated for the specific process.

<QueryList>
  <Query Id="0" Path="System">
    <Select Path="Security">
        *[System[Provider[@Name='Microsoft-Windows-Security-Auditing'] and Task = 13312 and (band(Keywords,9007199254740992)) and (EventID=4688)]]
        and
        *[EventData[Data[@Name='NewProcessName'] and (Data='C:\temp\process.exe')]]
    </Select>
  </Query>
</QueryList>



Share/Bookmark

Tuesday, May 26, 2020

Yammer: Native Mode - Reading the Alignment Report

Whilst performing a yammer migration to Native Mode.. I hit an issue where I created an alignment Report... Hoping this would give me clear insight into what was about to happen... However, the format the report is in is YAML...

I have no Yaml tools, so I wanted to get it into Excel...

It seemed like the quickest path, would be to convert to JSON, and then use excel json import capabilities.

So I used an online YAML to JSON converter...
https://onlineyamltools.com/convert-yaml-to-json

It worked very well for my purpose, and I got my report into json format.

Now to import to excel, goto the data tab.

Using the Get Data\From File\From JSON option


So then we are presented with 2 options groups and users. So what I did was to import each of these to their own worksheet. So lets start with Groups. Click on Record next to group


Now we are presented with a multitude of records, now lets get these into table...


Now we will expand out the record field (I just expand all fields, but you can be selective when the dialog appears).


Have a scan through the top of the column names, and look to see if you can expand any more.


Once you are happy you can import into excel, but clicking close and load. You should have a new worksheet with all the data you need. (You can repeat this process for the Users)


I must say that whilst I did find this information interesting, I still hit issues that I needed to fix..
And the move to Native Mode, takes forever and we only had a small instance... In fact the SLA from microsoft for Yamme with under 100,000 files is 30 days, and over 45 days... lol... First run for me took a few hours to run, before failing.. Then using the error report I was able to delete the problem file, and then rerun... again it took hours...








Share/Bookmark