> For the complete documentation index, see [llms.txt](https://docs.sealights.io/knowledgebase/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sealights.io/knowledgebase/setup-and-configuration/troubleshooting-faq/.net-.netcore/keeping-your-agent-updated.md).

# Keeping Your Agent Updated

### Problem <a href="#problem" id="problem"></a>

When configuring the SeaLights agent for DotNet, it isn't easy to manage the agent files in the correct version - especially in standalone environments (containers, backend servers, etc)

### Solution <a href="#solution" id="solution"></a>

The following PowerShell script checks for the recommended agent and latest version, and in case it does not exist locally - downloads & unzips it in the given directory.

#### Downloading the Recommended Agent set in settings <a href="#downloading-the-recommended-agent-set-in-settings" id="downloading-the-recommended-agent-set-in-settings"></a>

{% code overflow="wrap" lineNumbers="true" %}

```powershell
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$previousProgressPref=$global:ProgressPreference
$global:ProgressPreference = "SilentlyContinue" #Disable Progress bar to speed up download and expand

$sldomain="mycompany.sealights.co" #Update with your customer domain
$slToken="$(Get-Content sltoken.txt)" #Prefer a credential Environment variable for the token

Write-Output "Retrieve version from Sealights settings..." 
$slHeader=@{'Accept'='application/json'; 'Authorization'="Bearer $slToken"}
$SLSettingsVersion = ((iwr -Uri https://$sldomain/api/v2/agents/dotnet/recommended -UseBasicParsing -Headers $slHeader).Content | ConvertFrom-Json | Select-Object agent).agent.version

$SLAgentPath=".\SL.DotNet\"
$SlAgentVersionPath = $(Join-Path -Path $SLAgentPath -ChildPath "version.txt")

if( $(Test-Path -Path $SlAgentVersionPath -PathType Leaf) ) 
{
    $SLLocalVersion=Get-Content $SlAgentVersionPath
 
    if ( $SLLocalVersion -eq $SLSettingsVersion )
	{
        Write-Output "Skipping Download - Local agent matches current settings version: $SLLocalVersion"
	} else {
        Write-Output "Local agent is not using the latest version. Deleting local agent."
        Remove-Item -Recurse -Force $SLAgentPath
		#Get-ChildItem -path $SLAgentPath -include * -Recurse -exclude sltoken.txt -erroraction silentlycontinue | Remove-Item -Force -Verbose
	}
}

if( -Not $(Test-Path -Path $SlAgentVersionPath -PathType Leaf) ) 
{
	Write-Output "Download Sealights DotNet agent set in settings..." 
	iwr -OutFile .\sealights-dotnet-agent.zip -UseBasicParsing -Uri http://agents.sealights.co/SL.DotNet/SL.DotNet-$SLSettingsVersion.zip 
	Write-Output "Expanding downloaded archive and placing token..." 
	Expand-Archive .\sealights-dotnet-agent.zip -DestinationPath $SLAgentPath -Force
	Remove-Item -Force .\sealights-dotnet-agent.zip
	Get-ChildItem -Directory -Path .\SL.DotNet\ | Foreach-Object { $slToken | Out-File -NoNewline -Force (Join-Path $_.FullName "sltoken.txt") }
	Write-Output "Sealights agent version used is: $(Get-Content $SlAgentVersionPath)"  
}

#Restore progress bar
$global:ProgressPreference = $previousProgressPref
#End of script
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.sealights.io/knowledgebase/setup-and-configuration/troubleshooting-faq/.net-.netcore/keeping-your-agent-updated.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
