{"id":810787,"date":"2026-05-21T11:47:22","date_gmt":"2026-05-21T11:47:22","guid":{"rendered":"https:\/\/www.ninjaone.com\/?post_type=script_hub&#038;p=810787"},"modified":"2026-05-21T11:47:22","modified_gmt":"2026-05-21T11:47:22","slug":"como-localizar-arquivos-de-custo-excessivo-no-powershell","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/pt-br\/script-hub\/como-localizar-arquivos-de-custo-excessivo-no-powershell\/","title":{"rendered":"Como usar o PowerShell para localizar com efici\u00eancia arquivos OST grandes demais"},"content":{"rendered":"<p>No local de trabalho digitalizado de hoje, o gerenciamento eficaz dos espa\u00e7os de armazenamento nos sistemas de computador \u00e9 fundamental. Como dependemos cada vez mais da comunica\u00e7\u00e3o digital, uma ferramenta em que muitos profissionais confiam \u00e9 o Microsoft Outlook. Com o uso prolongado, <a href=\"https:\/\/www.techopedia.com\/definition\/15091\/offline-storage-table-file-ost-file\" target=\"_blank\" rel=\"noopener\">os arquivos OST (Outlook Offline Storage Table)<\/a> podem aumentar significativamente de tamanho, ocupando potencialmente grandes quantidades de espa\u00e7o em disco. Aqui, apresentamos um script do PowerShell que ajuda os profissionais de TI a <strong>localizar&nbsp;arquivos OST de tamanho excessivo<\/strong><\/p>\n<h2>Hist\u00f3rico<\/h2>\n<p>O arquivo OST \u00e9 essencialmente uma c\u00f3pia dos itens da caixa de correio do Exchange Server. Com o passar do tempo, \u00e0 medida que mais dados s\u00e3o acumulados, esses arquivos podem aumentar, o que representa desafios de armazenamento. Especialmente para profissionais de TI e <a href=\"https:\/\/www.ninjaone.com\/what-is-an-msp\/\">provedores de servi\u00e7os gerenciados (MSPs)<\/a>, manter o controle sobre esses arquivos grandes \u00e9 essencial para garantir o desempenho ideal do sistema e gerenciar o armazenamento com efici\u00eancia. N\u00e3o se trata apenas de liberar espa\u00e7o; trata-se de entender o comportamento do usu\u00e1rio, otimizar os recursos e evitar poss\u00edveis problemas.<\/p>\n<h2>O roteiro<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\">&lt;#\r\n.SYNOPSIS\r\n    Find large OST files in the user's folder or recursively under C:.\r\n.DESCRIPTION\r\n    Find large OST files in the user's folder or recursively under C:.\r\n.PARAMETER MinSize\r\n    The minimum file size. This expects the file size to be in gigabytes.\r\n.PARAMETER AllFolders\r\n    Will search all folders under C:.\r\n.EXAMPLE\r\n     -MinSize 50\r\n    Search for OST files larger than 50GB in each user's Outlook folder.\r\n.EXAMPLE\r\n     -AllFolders -MinSize 50\r\n    Search for OST files larger than 50GB under C: recursively.\r\n.OUTPUTS\r\n    String[]\r\n.NOTES\r\n    Minimum OS Architecture Supported: Windows 10, Windows Server 2016\r\n    Exit code 1: If at least 1 OST was found larger than MinSize\r\n    Exit code 0: If no OST's where found larger than MinSize\r\n    Release Notes:\r\n    Initial Release\r\nBy using this script, you indicate your acceptance of the following legal terms as well as our Terms of Use at https:\/\/www.ninjaone.com\/terms-of-use.\r\n    Ownership Rights: NinjaOne owns and will continue to own all right, title, and interest in and to the script (including the copyright). NinjaOne is giving you a limited license to use the script in accordance with these legal terms. \r\n    Use Limitation: You may only use the script for your legitimate personal or internal business purposes, and you may not share the script with another party. \r\n    Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library or website belonging to or under the control of any other software provider. \r\n    Warranty Disclaimer: The script is provided \u201cas is\u201d and \u201cas available\u201d, without warranty of any kind. NinjaOne makes no promise or guarantee that the script will be free from defects or that it will meet your specific needs or expectations. \r\n    Assumption of Risk: Your use of the script is at your own risk. You acknowledge that there are certain inherent risks in using the script, and you understand and assume each of those risks. \r\n    Waiver and Release: You will not hold NinjaOne responsible for any adverse or unintended consequences resulting from your use of the script, and you waive any legal or equitable rights or remedies you may have against NinjaOne relating to your use of the script. \r\n    EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).\r\n#&gt;\r\n[CmdletBinding()]\r\nparam (\r\n    [Parameter()]\r\n    [double]\r\n    $MinSize = 50,\r\n    [switch]\r\n    $AllFolders\r\n)\r\n\r\nbegin {\r\n    function Test-IsElevated {\r\n        $id = [System.Security.Principal.WindowsIdentity]::GetCurrent()\r\n        $p = New-Object System.Security.Principal.WindowsPrincipal($id)\r\n        $p.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)\r\n    }\r\n}\r\nprocess {\r\n    if (-not (Test-IsElevated)) {\r\n        Write-Error -Message \"Access Denied. Please run with Administrator privileges.\"\r\n        exit 1\r\n    }\r\n    $script:Found = $false\r\n\r\n    if ($AllFolders) {\r\n        $FoundFiles = Get-ChildItem C: -Filter *.ost -Recurse -Force -ErrorAction SilentlyContinue | Where-Object { $_.Length \/ ($MinSize * 1GB) -gt 1 }\r\n        $FoundFiles | Select-Object FullName, Length | ForEach-Object {\r\n            $Name = $_.FullName\r\n            $Size = $_.Length\r\n            Write-Host \"$Name $Size bytes\"\r\n        }\r\n        # If you wish to automatically remove the file(s) uncomment the line below. Do note that this is permanent! Make backups!\r\n        # $FoundFiles | Remove-Item -Force -Confirm:$false\r\n        if ($FoundFiles) {\r\n            $script:Found = $true\r\n        }\r\n    }\r\n    else {\r\n        $UsersFolder = \"C:Users\"\r\n        $Outlook = \"AppDataLocalMicrosoftOutlook\"\r\n        Get-ChildItem -Path $UsersFolder | ForEach-Object {\r\n            $User = $_\r\n            $Folder = \"$UsersFolder$User$Outlook\"\r\n            if ($(Test-Path -Path $Folder)) {\r\n                $FoundFiles = Get-ChildItem $Folder -Filter *.ost | Where-Object { $_.Length \/ ($MinSize * 1GB) -gt 1 }\r\n                $FoundFiles | Select-Object FullName, Length | ForEach-Object {\r\n                    $Name = $_.FullName\r\n                    $Size = $_.Length\r\n                    Write-Host \"$Name $Size bytes\"\r\n                }\r\n                # If you wish to automatically remove the file(s) uncomment the line below. Do note that this is permanent! Make backups!\r\n                # $FoundFiles | Remove-Item -Force -Confirm:$false\r\n                if ($FoundFiles) {\r\n                    Write-Verbose \"Found\"\r\n                    $script:Found = $true\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    if ($script:Found) {\r\n        exit 1\r\n    }\r\n    exit 0\r\n}\r\nend {}<\/pre>\n<p>&nbsp;<\/p>\n\n<div class=\"in-context-cta\"><p style=\"text-align: center;\">Acesse mais de 300 scripts no NinjaOne Dojo<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/www.ninjaone.com\/freetrialform\/\">Obter acesso<\/a><\/p>\n<\/div>\n<h2>Detalhamento<\/h2>\n<p><strong>O script pode ser compartimentado em v\u00e1rias \u00e1reas principais:<\/strong><\/p>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\"><strong>Sinopse e descri\u00e7\u00e3o<\/strong>: Fornece uma vis\u00e3o geral do objetivo do script, que \u00e9 localizar arquivos OST grandes na pasta de um usu\u00e1rio ou recursivamente em C:.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\"><strong>Par\u00e2metros<\/strong>: Determina os detalhes da pesquisa. Isso inclui o tamanho m\u00ednimo do arquivo (em GB) e a possibilidade de pesquisar todas as pastas em C:.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\"><strong>Verifica\u00e7\u00e3o da eleva\u00e7\u00e3o<\/strong>: Antes de se aprofundar na pesquisa de arquivos, o script verifica se h\u00e1 privil\u00e9gios administrativos. Sem esses direitos, o script n\u00e3o pode sondar n\u00edveis mais profundos do sistema.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\"><strong>L\u00f3gica de pesquisa de arquivos<\/strong>: Dependendo dos par\u00e2metros escolhidos, o script procura em todas as pastas em C: por arquivos OST maiores do que o tamanho especificado ou restringe a pesquisa \u00e0 pasta do Outlook de cada usu\u00e1rio.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\"><strong>Sa\u00edda<\/strong>: Se forem encontrados arquivos OST grandes demais, o script imprimir\u00e1 o caminho completo e o tamanho em bytes. Al\u00e9m disso, o script tem linhas comentadas para excluir esses arquivos &#8211; essa a\u00e7\u00e3o \u00e9 deixada a crit\u00e9rio do profissional de TI.<\/li>\n<\/ul>\n<h2>Casos de uso em potencial<\/h2>\n<p>Imagine uma administradora de TI, Jane, em uma empresa de grande porte. Ela recebe reclama\u00e7\u00f5es de v\u00e1rios departamentos sobre o atraso do sistema e a diminui\u00e7\u00e3o do desempenho. Ap\u00f3s alguns testes de diagn\u00f3stico, Jane identifica problemas de armazenamento &#8211; v\u00e1rios arquivos grandes ocupando espa\u00e7o essencial. Com esse script, Jane pode identificar rapidamente os arquivos OST de tamanho excessivo e determinar o melhor curso de a\u00e7\u00e3o, seja arquivando, excluindo ou realocando os arquivos.<\/p>\n<h2>Compara\u00e7\u00f5es<\/h2>\n<p>Embora existam ferramentas e softwares baseados em GUI que fornecem an\u00e1lise de disco, a vantagem desse script do PowerShell \u00e9 sua especificidade e seu potencial de automa\u00e7\u00e3o. Ele visa diretamente os arquivos OST e pode ser incorporado a fluxos de trabalho de automa\u00e7\u00e3o maiores, ao contr\u00e1rio de muitas ferramentas de terceiros que fornecem vis\u00f5es gerais mais amplas sem o mesmo n\u00edvel de personaliza\u00e7\u00e3o.<\/p>\n<h2>Implica\u00e7\u00f5es<\/h2>\n<p>Localizar e gerenciar arquivos OST grandes \u00e9 mais do que um exerc\u00edcio de armazenamento. Ele aborda a seguran\u00e7a de TI. Arquivos OST grandes demais podem ser indicativos de ac\u00famulo de dados ou at\u00e9 mesmo de viola\u00e7\u00f5es de dados, em que grandes quantidades de dados s\u00e3o exportadas. O gerenciamento proativo desses arquivos pode reduzir os poss\u00edveis riscos.<\/p>\n<h2>Recomenda\u00e7\u00f5es<\/h2>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\">Sempre fa\u00e7a backup dos dados antes de executar scripts que possam excluir arquivos.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"2\" data-aria-level=\"1\">Execute rotineiramente esses scripts para manter o desempenho ideal do sistema.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\">N\u00e3o remova o coment\u00e1rio da op\u00e7\u00e3o de exclus\u00e3o, a menos que tenha certeza das ramifica\u00e7\u00f5es.<\/li>\n<\/ul>\n<h2>Considera\u00e7\u00f5es finais<\/h2>\n<p>Gerenciar arquivos grandes, especialmente arquivos OST, pode ser uma tarefa dif\u00edcil. Mas ferramentas como o <a href=\"https:\/\/www.ninjaone.com\/pt-br\/\">NinjaOne<\/a> oferecem solu\u00e7\u00f5es robustas para o <a href=\"https:\/\/www.ninjaone.com\/pt-br\/\">gerenciamento geral de TI<\/a>. Juntamente com scripts personalizados, como o detalhado aqui, os profissionais podem garantir <a href=\"https:\/\/www.ninjaone.com\/pt-br\/eficiencia\/\">a efici\u00eancia do sistema, a otimiza\u00e7\u00e3o do armazenamento e a minimiza\u00e7\u00e3o de riscos<\/a> no cen\u00e1rio de TI em constante evolu\u00e7\u00e3o.<\/p>\n","protected":false},"author":35,"featured_media":144339,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"_relevanssi_hide_post":"","_relevanssi_hide_content":"","_relevanssi_pin_for_all":"","_relevanssi_pin_keywords":"","_relevanssi_unpin_keywords":"","_relevanssi_related_keywords":"","_relevanssi_related_include_ids":"","_relevanssi_related_exclude_ids":"","_relevanssi_related_no_append":"","_relevanssi_related_not_related":"","_relevanssi_related_posts":"","_relevanssi_noindex_reason":"","_lmt_disableupdate":"no","_lmt_disable":""},"operating_system":[4212],"use_cases":[12457],"class_list":["post-810787","script_hub","type-script_hub","status-publish","has-post-thumbnail","hentry","script_hub_category-windows"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/script_hub\/810787","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/script_hub"}],"about":[{"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/types\/script_hub"}],"author":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/comments?post=810787"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/media\/144339"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/media?parent=810787"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/operating_system?post=810787"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/use_cases?post=810787"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}