title: Disconnect an Azure VM from a loganalytics workspace
body: <p>i'm looking for a powershell way to disconnect a  virtual machine from an OMS workspace.</p>
  
  <p>I wrote a powershell script to move a VM to an other subscription. So i have to re-connect this VM from 'source workspace' to 'destination workspace'. </p>
  
  <p>Just removing OMS extension show me the virtual machine as "Not connected" into Azure portal "Log Analytics workspace >Workspace Data Sources>Virtual machines".</p>
  
  <p>This cmdlet should do the tricks (<a href="https://docs.microsoft.com/en-us/powershell/module/AzureRM.OperationalInsights/Remove-AzureRmOperationalInsightsDataSource?view=azurermps-6.13.0" rel="nofollow noreferrer">the doc is not really clear</a>), but i always have the same message</p>
  
  <pre><code>remove-AzureRmOperationalInsightsDataSource -Workspace $OmsWkspceITS -Name CentosMove
  Confirm
  Are you sure you want to remove data source 'CentosMove' in workspace 'itsoms'?
  [Y] Yes [N] No [S] Suspend [?] Help (default is "Yes"): yes
  WARNING: DataSource 'CentosMove' does not exist in workspace 'itsoms'.
  </code></pre>
  
  <p>(CentosMove is my VM name).</p>
  
  <p>Our ITSOMS workspace is used for years now with hundred of VM, many solutions, NSG logflows analytics,.. </p>
  
  <pre><code>$OmsWkspceITS
  
  
  Name              : itsoms
  ResourceGroupName : rg_its_exploit
  ResourceId        : /subscriptions/blablabla/resourcegroups/blabla/providers/microsoft.operationalinsights/workspaces/itsoms
  Location          : westeurope
  Tags              :
  Sku               : standalone
  CustomerId        : xx
  PortalUrl         : https://weu.mms.microsoft.com/Accou...
  ProvisioningState : Succeeded
  </code></pre>
  
  <p>The only Datasources i can get with this cmdlet are those like this one</p>
  
  <pre><code>Get-AzureRmOperationalInsightsDataSource -WorkspaceName $OmsWkspceITS.Name -ResourceGroupName $OmsWkspceITS.ResourceGroupName -Name DataSource_LinuxSyslog_syslog
  
  
  Name              : DataSource_LinuxSyslog_syslog
  ResourceGroupName : rg_its_exploit
  WorkspaceName     : itsoms
  ResourceId        : /subscriptions/xx/resourceGroups/rg_its_exploit/providers/Microsoft.OperationalInsights/workspaces/itsoms/datasources/DataSource_LinuxSyslog_syslog
  Kind              : LinuxSyslog
  Properties        : {"syslogName":"syslog".....}
  </code></pre>
  
  <p>I'm maybe not looking at the right cmdlet i think ...</p>
  
  <p>Thanks for your help :) </p>